當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。