Exemplo n.º 1
0
        public string Save(string path, cfLangType clt, KeelKit.Generators.BaseGengerator.DGetFileNames getfilename)
        {
            string          result   = null;
            CodeDomProvider provider = BaseGengerator.GetProvider(clt);

            if (provider != null)
            {
                string             filename = getfilename(path, provider.FileExtension);
                IndentedTextWriter tw       = new IndentedTextWriter(new StreamWriter(filename, false, Encoding.UTF8), "    ");
                provider.GenerateCodeFromCompileUnit(ccu, tw, new CodeGeneratorOptions());
                tw.Close();
                result = filename;
            }
            return(result);
        }
Exemplo n.º 2
0
        public string Save(string path, cfLangType clt, KeelKit.Generators.BaseGengerator.DGetFileNames getfilename)
        {
            CodeDomProvider provider = BaseGengerator.GetProvider(clt);

            string filename = getfilename != null?getfilename(path, provider.FileExtension) : GetFileNames(path, provider.FileExtension);

            IndentedTextWriter tw = new IndentedTextWriter(new StreamWriter(filename, false, Encoding.UTF8), "    ");

            provider.GenerateCodeFromCompileUnit(ccu, tw, new CodeGeneratorOptions());
            tw.Close();
            string context = System.IO.File.ReadAllText(filename, Encoding.UTF8);

            if (!context.Contains("<auto-generated>") && ccu.Namespaces.Count > 0)
            {
                ccu.Namespaces[0].Comments.Clear();
                ccu.Namespaces[0].Comments.Add(new CodeCommentStatement(BaseGengerator.AddKeelKitInfo()));
                tw = new IndentedTextWriter(new StreamWriter(filename, false, Encoding.UTF8), "    ");
                provider.GenerateCodeFromCompileUnit(ccu, tw, new CodeGeneratorOptions());
                tw.Close();
            }
            return(filename);
        }