Beispiel #1
0
        /// <summary>
        /// Write code with TypeScript CodeDOM
        /// </summary>
        /// <param name="writer"></param>
        protected override void WriteCode(TextWriter writer)
        {
            //if (writer == null)
            //	throw new ArgumentNullException("writer", "No TextWriter instance is defined.");

            using CodeDomProvider provider = new Fonlow.TypeScriptCodeDom.TypeScriptCodeProvider(true);
            CodeGeneratorOptions options = new CodeGeneratorOptions()
            {
                BracingStyle = "JS", IndentString = "\t"
            };

            provider.GenerateCodeFromCompileUnit(codeCompileUnit, writer, options);
        }
        /// <summary>
        /// Save TypeScript codes generated into a TextWriter.
        /// </summary>
        /// <param name="writer"></param>
        public void WriteCode(TextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer", "No TextWriter instance is defined.");
            }

            var provider = new Fonlow.TypeScriptCodeDom.TypeScriptCodeProvider(true);
            CodeGeneratorOptions options = Fonlow.TypeScriptCodeDom.TsCodeGenerationOptions.Instance;

            options.BracingStyle = "JS";
            options.IndentString = "\t";

            provider.GenerateCodeFromCompileUnit(targetUnit, writer, options);
        }