• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript xml2js.Builder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中xml2js.Builder的典型用法代码示例。如果您正苦于以下问题:TypeScript Builder类的具体用法?TypeScript Builder怎么用?TypeScript Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Builder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

            parser.parseString(xmlContents, function (err, result) {
                if (err) {
                    tl.warning(tl.loc('ErrorWhileReadingRunSettings', err));
                    tl.debug("Error occured while overriding test run parameters. Continuing...");
                    defer.resolve(settingsFile);
                    return defer.promise;
                }

                if (result.RunSettings && result.RunSettings.TestRunParameters && result.RunSettings.TestRunParameters[0] &&
                    result.RunSettings.TestRunParameters[0].Parameter) {
                    var parametersArray = result.RunSettings.TestRunParameters[0].Parameter;
                    parametersArray.forEach(function (parameter) {
                        var key = parameter.$.name;
                        if (overrideParameters[key]) {
                            parameter.$.value = overrideParameters[key];
                        }
                    });
                    tl.debug("Overriding test run parameters.");
                    var builder = new xml2js.Builder();
                    var overridedRunSettings = builder.buildObject(result);
                    saveToFile(overridedRunSettings, runSettingsExt)
                        .then(function (fileName) {
                            defer.resolve(fileName);
                        })
                        .fail(function (err) {
                            tl.debug("Error occured while overriding test run parameters. Continuing...");
                            tl.warning(err);
                            defer.resolve(settingsFile);
                        });
                }
                else {
                    tl.debug("No test run parameters found to override.");
                    defer.resolve(settingsFile);
                }
            });
开发者ID:ColinDabritz,项目名称:vsts-tasks,代码行数:35,代码来源:vstest.ts


示例2: writeJsonAsXmlFile

export function writeJsonAsXmlFile(filePath: string, jsonContent: any): Q.Promise<void> {
    let builder = new xml2js.Builder();
    tl.debug("Writing JSON as XML file: " + filePath);
    let xml = builder.buildObject(jsonContent);
    xml = str(xml).replaceAll("&#xD;", "").s;
    return writeFile(filePath, xml);
}
开发者ID:HSAR,项目名称:vso-agent-tasks,代码行数:7,代码来源:utilities.ts


示例3: writeXmlFile

function writeXmlFile(result: any, settingsFile: string, fileExt: string, exitErrorMessage: string): Q.Promise<string> {
    var defer = Q.defer<string>();
    var builder = new xml2js.Builder();
    var runSettingsForTestImpact = builder.buildObject(result);
    saveToFile(runSettingsForTestImpact, fileExt)
        .then(function (fileName) {
            cleanUp(settingsFile);
            defer.resolve(fileName);
            return defer.promise;
        })
        .fail(function (err) {
            tl.debug(exitErrorMessage);
            tl.warning(err);
            defer.resolve(settingsFile);
        });
    return defer.promise;
}
开发者ID:ColinDabritz,项目名称:vsts-tasks,代码行数:17,代码来源:vstest.ts


示例4: function

                    parser.parseString(xmlContents, function(err, result) {
                        if (err) {
                            tl.warning("Error occured while reading run settings file. Error : " + err);
                            tl.debug("Error occured while setting run in parallel. Continuing...");
                            defer.resolve(settingsFile);
                            return defer.promise;
                        }

                        if (result.RunSettings === undefined) {
                            tl.warning("Failed to set run in parallel. Invalid run settings file.");
                            defer.resolve(settingsFile);
                            return defer.promise;
                        }

                        if (!result.RunSettings) {
                            result.RunSettings = { RunConfiguration: { MaxCpuCount: 0 } };
                        }
                        else if (!result.RunSettings.RunConfiguration || !result.RunSettings.RunConfiguration[0]) {
                            result.RunSettings.RunConfiguration = { MaxCpuCount: 0 };
                        }
                        else {
                            var runConfigArray = result.RunSettings.RunConfiguration[0];
                            runConfigArray.MaxCpuCount = 0;
                        }

                        var builder = new xml2js.Builder();
                        var runSettingsForParallel = builder.buildObject(result);
                        saveToFile(runSettingsForParallel)
                            .then(function(fileName) {
                                cleanUp(settingsFile);
                                defer.resolve(fileName);
                                return defer.promise;
                            })
                            .fail(function(err) {
                                tl.debug("Error occured while setting run in parallel. Continuing...");
                                tl.warning(err);
                                defer.resolve(settingsFile);
                            });
                    });
开发者ID:Alekseypv,项目名称:vsts-tasks,代码行数:39,代码来源:vstest.ts


示例5: function

 _.defer( () => {
   try {
     // 1 Copy the public properties and _name to a destination object for serialization.
     var destObj = {};
     _.each( _.keys( viewData) , function(key: string) {
       //
       if ( key === '_name' ) {
         destObj['name'] = viewData[key];
         resourceName = viewData[key];
       }
       else if ( key.indexOf('_') === 0 )
         return;
       else {
         //console.log('['+key+'] is '+viewData[key] );
         destObj[key] = viewData[key];
       }
     });
     // 2 - build the embodiment serializing the data as a Buffer
     // log.info('Serializing "%s"',JSON.stringify(destObj));
     var dataString = '';
     switch(mimeType) {
       case 'application/xml':
       case 'text/xml':
         var builder = new xml2js.Builder({ rootName: resourceName, renderOpts : { 'pretty': false }, headless: true });
         dataString = builder.buildObject( destObj );
         break;
       default:
         dataString = JSON.stringify( destObj );
         break;
     }
     // log.info('Delivering: "%s"',dataString);
     var e = new relaxjs.Embodiment( mimeType, 200, new Buffer( dataString,'utf-8' ) );
     later.resolve( e );
   }
   catch( err ) {
     log.error(err);
     later.reject( new relaxjs.RxError('JSON Serialization error: '+err ) )
   }
 });
开发者ID:micurs,项目名称:relaxjs,代码行数:39,代码来源:internals.ts


示例6: build

 build(rootObj): string {
   return this.builder.buildObject(rootObj);
 }
开发者ID:Codesleuth,项目名称:esendex-node,代码行数:3,代码来源:xmlbuilder.ts


示例7: saveXML

export function saveXML(xmlobj:{}, path:string):Promise<string> {
    var contents = builder.buildObject(xmlobj);
    return writeFile(path, contents).thenReturn(path);
}
开发者ID:KeeTraxx,项目名称:kexcel,代码行数:4,代码来源:Util.ts



注:本文中的xml2js.Builder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript xml2js.Parser类代码示例发布时间:2022-05-25
下一篇:
TypeScript xml2js.parseString函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap