コード例 #1
0
            public void init()
            {
                TsConfig.prepareInstance();
                TsLog.prepareInstance(LOG_FILE_NM, null);

                m_device_unique_id   = NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString();
                m_device_unique_name = Environment.MachineName;
            }
コード例 #2
0
        public void deleteConfigSection(string _section)
        {
            TsConfig config = TsConfig.getInstance();

            if (null != config)
            {
                config.deleteSection(_section);
            }
        }
コード例 #3
0
        public void writeConfigLong(string _section, string _key, long _value)
        {
            TsConfig config = TsConfig.getInstance();

            if (null != config)
            {
                config.writeLong(_section, _key, _value);
            }
        }
コード例 #4
0
        public void LoadProject()
        {
            var path = Path.GetFullPath(@"C:\github\NgAnalyze\TestProject\tsconfig.json");

            _tsConfig = new TsConfigReader().LoadFromFile(path);

            AutoMapper.Mapper.Initialize(config => Mapping.Configuration(config, _tsConfig.RootDir));
            _project = TsProject <TypescriptFile> .Load(_tsConfig, TypescriptFile.Load);
        }
コード例 #5
0
        public Int32 readConfigLong(string _section, string _key, long _default_value = 0)
        {
            TsConfig config = TsConfig.getInstance();

            if (null != config)
            {
                return(config.readLong(_section, _key, _default_value));
            }
            return(0);
        }
コード例 #6
0
        public string readConfigString(string _section, string _key, string _default_value = "")
        {
            TsConfig config = TsConfig.getInstance();

            if (null != config)
            {
                return(config.readString(_section, _key, _default_value));
            }
            return("");
        }
コード例 #7
0
ファイル: Typescript.cs プロジェクト: mikel21/TsBuilder
        private static async Task CreateConfigAsync(EnvironmentType environment, string configFile)
        {
            var config = new TsConfig(environment);

            var data = JsonSerializer.Serialize(config);

            using (var fileStream = File.Create(configFile))
            {
                await fileStream.WriteAsync(data);
            }
        }
コード例 #8
0
            public void deInit()
            {
                if (null != TsConfig.getInstance())
                {
                    TsConfig.releaseInstance();
                }

                if (null != TsLog.getInstance())
                {
                    TsLog.releaseInstance();
                }
            }
コード例 #9
0
 private static string GetTsConfigOutDir(string tsConfigBytes)
 {
     try
     {
         TsConfig tsConfig = JsonConvert.DeserializeObject <TsConfig>(tsConfigBytes);
         if (tsConfig.GetType().GetProperty("compilerOptions") == null)
         {
             return("/");
         }
         var compilerOptions = tsConfig.compilerOptions;
         return(compilerOptions.GetType().GetProperty("outDir") != null
             ? !compilerOptions.outDir.StartsWith("/")
                 ? compilerOptions.outDir = "/" + compilerOptions.outDir
                 : compilerOptions.outDir
             : "/");
     }
     catch (Exception ex)
     {
         ExceptionHandler.LogException(Logger, Resource.Error_UnableToGetTsconfigOutdir, ex);
         OutputLogger.WriteToOutputWindow(Resource.Error_UnableToGetTsconfigOutdir, MessageType.Error);
         return("/");
     }
 }
コード例 #10
0
ファイル: TsProject.cs プロジェクト: yngvebn/NgAnalyze
        private TsProject(TsConfig tsconfig, Func <string, string, T> createCompiled)
        {
            _tsconfig = tsconfig;

            var projectFiles = GetProjectFiles().ToList();
            int i            = 0;

            Console.WriteLine("Loading...");
            var files = new List <TypeScriptAST>();

            Parallel.ForEach(projectFiles, file =>
            {
                i++;
                Console.WriteLine($"Loading {i}/{projectFiles.Count} - {file}");
                files.Add(new TypeScriptAST(file, Path.GetFileName(file)));
            });
            Files = files;
            Console.WriteLine("Compiling...");
            i = 0;
            var compiled = new List <T>();

            Parallel.ForEach(projectFiles, file =>
            {
                i++;
                Console.WriteLine($"Compiling {i}/{projectFiles.Count} - {file}");
                try
                {
                    compiled.Add(createCompiled(file, tsconfig.RootDir));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            });
            Compiled = compiled;
        }
コード例 #11
0
        /// <summary>
        /// Generate Azure TypeScript client code
        /// </summary>
        /// <param name="cm"></param>
        /// <returns></returns>
        public override async Task Generate(CodeModel cm)
        {
            var codeModel = cm as CodeModelTSa;

            if (codeModel == null)
            {
                throw new InvalidCastException("CodeModel is not a Azure TypeScript code model.");
            }

            codeModel.PackageName    = Settings.Instance.PackageName;
            codeModel.PackageVersion = Settings.Instance.PackageVersion;

            // Service client
            var serviceClientTemplate = new AzureServiceClientTemplate {
                Model = codeModel
            };

            await Write(serviceClientTemplate, codeModel.Name.ToCamelCase() + ".ts");
            await Write(new AzureServiceClientContextTemplate { Model = codeModel }, codeModel.ContextName.ToCamelCase() + ".ts");

            var modelIndexTemplate = new AzureModelIndexTemplate {
                Model = codeModel
            };

            await Write(modelIndexTemplate, Path.Combine("models", "index.ts"));

            var mapperIndexTemplate = new AzureMapperIndexTemplate {
                Model = codeModel
            };

            await Write(mapperIndexTemplate, Path.Combine("models", "mappers.ts"));

            //MethodGroups
            if (codeModel.MethodGroupModels.Any())
            {
                var methodGroupIndexTemplate = new MethodGroupIndexTemplate {
                    Model = codeModel
                };
                await Write(methodGroupIndexTemplate, Path.Combine("operations", "index.ts"));

                foreach (var methodGroupModel in codeModel.MethodGroupModels)
                {
                    var methodGroupTemplate = new AzureMethodGroupTemplate {
                        Model = methodGroupModel
                    };
                    await Write(methodGroupTemplate, Path.Combine("operations", methodGroupModel.TypeName.ToCamelCase() + ".ts"));
                }
            }

            var generateMetadata = Singleton <GeneratorSettingsTS> .Instance.GenerateMetadata;

            if (generateMetadata)
            {
                // package.json
                var packageJson = new PackageJson {
                    Model = codeModel
                };
                await Write(packageJson, Path.Combine("../", "package.json"));

                // tsconfig.json
                var browserTsConfig = new TsConfig {
                    Model = new TsConfigModel(true)
                };
                await Write(browserTsConfig, Path.Combine("../", "tsconfig.json"));

                // webpack.config.js
                var webpackConfig = new WebpackConfig {
                    Model = codeModel
                };
                await Write(webpackConfig, Path.Combine("../", "webpack.config.js"));

                // .npmignore
                var npmIgnore = new NpmIgnore {
                    Model = codeModel
                };
                await Write(npmIgnore, Path.Combine("../", ".npmignore"));

                //README.md
                var readme = new AzureReadmeTemplate {
                    Model = codeModel
                };
                await Write(readme, Path.Combine("../", "README.md"));
            }
        }
コード例 #12
0
ファイル: TsProject.cs プロジェクト: yngvebn/NgAnalyze
 public static TsProject <T> Load <T>(TsConfig config, Func <string, string, T> createCompiled)
 {
     return(new TsProject <T>(config, createCompiled));
 }
コード例 #13
0
        /// <summary>
        ///     Generate TypeScript client code
        /// </summary>
        /// <param name="serviceClient"></param>
        /// <returns></returns>
        public override async Task Generate(CodeModel cm)
        {
            var codeModel = cm as CodeModelTS;

            if (codeModel == null)
            {
                throw new InvalidCastException("CodeModel is not a TypeScript code model.");
            }

            InitializeSettings(codeModel);

            // Service client
            var serviceClientTemplate = new ServiceClientTemplate {
                Model = codeModel
            };

            await Write(serviceClientTemplate, codeModel.Name.ToCamelCase() + ".ts");
            await Write(new ServiceClientContextTemplate { Model = codeModel }, codeModel.ContextName.ToCamelCase() + ".ts");

            //Models
            if (codeModel.ModelTypes.Any())
            {
                var modelIndexTemplate = new ModelIndexTemplate {
                    Model = codeModel
                };
                await Write(modelIndexTemplate, Path.Combine("models", "index.ts"));

                var mapperIndexTemplate = new MapperIndexTemplate {
                    Model = codeModel
                };
                await Write(mapperIndexTemplate, Path.Combine("models", "mappers.ts"));
            }

            bool serviceHasMappableParameters = codeModel.Methods
                                                .SelectMany(m => m.LogicalParameters)
                                                .Any(p => p.Location != ParameterLocation.Body);

            if (serviceHasMappableParameters)
            {
                await Write(new ParameterTemplate { Model = codeModel }, Path.Combine("models", "parameters.ts"));
            }

            //MethodGroups
            if (codeModel.MethodGroupModels.Any())
            {
                var methodGroupIndexTemplate = new MethodGroupIndexTemplate {
                    Model = codeModel
                };
                await Write(methodGroupIndexTemplate, Path.Combine("operations", "index.ts"));

                foreach (var methodGroupModel in codeModel.MethodGroupModels)
                {
                    var mappersTemplate = new MethodGroupMappersTemplate {
                        Model = methodGroupModel
                    };
                    await Write(mappersTemplate, Path.Combine("models", methodGroupModel.MappersModuleName + ".ts"));

                    var methodGroupTemplate = new MethodGroupTemplate {
                        Model = methodGroupModel
                    };
                    await Write(methodGroupTemplate, Path.Combine("operations", methodGroupModel.TypeName.ToCamelCase() + ".ts"));
                }
            }

            if (codeModel.GenerateMetadata)
            {
                // package.json
                var packageJson = new PackageJson {
                    Model = codeModel
                };
                await Write(packageJson, Path.Combine("../", "package.json"));

                //tsconfig.json
                var nodeTsConfig = new TsConfig {
                    Model = new TsConfigModel(false)
                };
                await Write(nodeTsConfig, Path.Combine("../", "tsconfig.json"));

                // webpack.config.js
                var webpackConfig = new WebpackConfig {
                    Model = codeModel
                };
                await Write(webpackConfig, Path.Combine("../", "webpack.config.js"));

                // .npmignore
                var npmIgnore = new NpmIgnore {
                    Model = codeModel
                };
                await Write(npmIgnore, Path.Combine("../", ".npmignore"));

                //README.md
                var readme = new ReadmeTemplate {
                    Model = codeModel
                };
                await Write(readme, Path.Combine("../", "README.md"));
            }
        }