private traverse()

in templates/legacy/windows-admin-center-extension-template/gulps/gulp-resjson/resjson-convert.ts [137:177]


    private traverse(keyItems: NameValuePair[], indent: number): void {
        const indentSpace = '    ';
        let indentName = '';
        for (let i = 0; i < indent; i++) {
            indentName += indentSpace;
        }

        let indentValue: string = indentName + indentSpace;
        if (keyItems.length > 0) {
            for (let item of keyItems) {
                if (indent === 0) {
                    this.outputDefinition.push(ResJsonConverter.openContent);
                    this.outputTypescript.push(ResJsonConverter.openContent);
                    this.outputInterface.push(ResJsonConverter.openContent);
                    this.outputDefinition.push('export declare module ' + item.name + ' {\r\n');
                    this.outputTypescript.push('export module ' + item.name + ' {\r\n    \'use strict\';\r\n');
                    this.outputInterface.push('export interface ' + item.name + ' {\r\n');
                } else {
                    this.outputDefinition.push(indentName + 'module ' + item.name + ' {\r\n');
                    this.outputTypescript.push(indentName + 'export module ' + item.name + ' {\r\n');
                    this.outputInterface.push(indentName + item.name + ': {\r\n');
                }

                let jsonOld = this.jsonNewValue(item.name);
                let results = this.scan(item.value);
                for (let item2 of results.dataItems) {
                    this.outputDefinition.push(indentValue + 'const ' + item2.name + ': string;\r\n');
                    this.outputTypescript.push(indentValue + 'export const ' + item2.name + ' = \'' + item2.value + '\';\r\n');
                    this.outputInterface.push(indentValue + item2.name + ': string;\r\n');
                    this.jsonAddValue(item2.name, item2.value);
                }

                this.traverse(results.keyItems, ++indent);
                this.jsonCurrent = jsonOld;

                this.outputDefinition.push(indentName + '}\r\n');
                this.outputTypescript.push(indentName + '}\r\n');
                this.outputInterface.push(indentName + '};\r\n');
            }
        }
    }