当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript xml2js.Builder类代码示例

本文整理汇总了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;未经允许,请勿转载。