示例#1
0
        /// <summary>
        ///     Compile a model for TypeScript.
        /// </summary>
        protected static void CompileTypeScript(ConversionKernel kernel, string fileName = "typescript", Func <ClassDescriptor, bool> predicate = null, bool minify = false)
        {
            var converter = kernel.CreateConverterForTypeScript(TypeScriptSpecification.TypeScript);
            var converted = converter.Convert(predicate);

            if (minify)
            {
                fileName += ".min";
            }

            converter.WriteToFile(converted, FilePath, fileName, minify);
        }
示例#2
0
        /// <summary>
        ///     Compile a model for DefinitelyTyped.
        /// </summary>
        protected static void CompileDefinitelyTyped(ConversionKernel kernel, string fileName = "reference", bool minify = false)
        {
            // Make sure the XML documentation is loaded
            var assemblyName = typeof(TestBase).Assembly.GetProjectName();

            kernel.LoadXmlDocumentation();

            var converter = kernel.CreateConverterForTypeScript(TypeScriptSpecification.Declaration);
            var converted = converter.Convert();

            if (minify)
            {
                fileName += ".min";
            }

            converter.WriteToFile(converted, FilePath, fileName, minify);
        }
示例#3
0
        public void CompileTypeScriptFileTest()
        {
            // 1: Create an instance of the ConversionKernel
            var assembly = typeof(SchoolViewModel).Assembly;

            using (var kernel = new ConversionKernel(assembly).LoadXmlDocumentation())
            {
                // 2: Create the ModelConverter instance for the requested script-language
                var converter = kernel.CreateConverterForTypeScript(TypeScriptSpecification.TypeScript);

                // 3: Invoke the Convert method to generate the script.
                var converted = converter.Convert();

                // Merge the generated script model(s) to one string.
                var contents = converter.MergeModelsToString(converted);

                var fileName = "typescript";

                converter.WriteToFile(converted, FilePath, fileName);
            }
        }