当前位置: 首页>>代码示例>>C#>>正文


C# CodeWriter.Write方法代码示例

本文整理汇总了C#中CodeWriter.Write方法的典型用法代码示例。如果您正苦于以下问题:C# CodeWriter.Write方法的具体用法?C# CodeWriter.Write怎么用?C# CodeWriter.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeWriter的用法示例。


在下文中一共展示了CodeWriter.Write方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SaveHeader

 /// <summary>
 /// Saves the file header to disk.
 /// </summary>
 internal override void SaveHeader(CodeWriter writer, PFile file)
 {
     writer.Write(file.Name);
     writer.Write(new FileInfo(file.FilePath).Length);
     writer.Write(file.LastModified.Ticks);
     writer.Write((int) file.Attributes);
 }
开发者ID:Zyphrax,项目名称:PixelCryptor,代码行数:10,代码来源:PFileComet.cs

示例2: GenerateInterface

        public string GenerateInterface(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine("define([\"dojo/request\", \"dojo/json\"], function (request, JSON) {");
            writer.PushIdent();
            writer.WriteLine("var serviceClient = {");
            writer.PushIdent();
            writer.WriteLine("urlString: '',");
            writer.WriteLine();

            int methodCount = intr.Methods.Count;
            for (int i = 0; i < methodCount; i++)
            {
                Method method = intr.Methods[i];
                string comma = i < methodCount - 1 ? "," : "";
                writer.Write(GenerateMethod(intr, method).Trim());
                writer.WriteLineNoIdent(comma);
                writer.WriteLine();
            }
            writer.PopIdent();
            writer.WriteLine("}");
            writer.WriteLine("return serviceClient;");
            writer.PopIdent();
            writer.Write("});");
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:26,代码来源:JavaScriptDojoAMDGenerator.cs

示例3: Generate

 public override string Generate(Schema schema)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLine("----- TABLES -----");
     writer.Write(GenerateTables(schema));
     writer.WriteLine("----- STORED PROCEDURES -----");
     writer.Write(GenerateStoredProcedures(schema));
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:9,代码来源:SqlServerDatabaseGenerator.cs

示例4: GenerateMethod

 public string GenerateMethod(Interface intr, Method method)
 {
     CodeWriter writer = new CodeWriter();
     writer.Write(generateMethodHeader(intr, method));
     writer.WriteLine(" {");
     writer.PushIdent();
     writer.WriteLine(generateMethodBody(intr, method));
     writer.PopIdent();
     writer.Write("}");
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:11,代码来源:AngularGenerator.cs

示例5: GenerateInterface

        public string GenerateInterface(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteFormat(".factory(\"{0}Client\", function($http, serviceUrl)", intr.Name);
            writer.WriteLineNoIdent(" {");
            writer.PushIdent();
            writer.WriteLine("return {");

            int methodCount = intr.Methods.Count;
            for (int i = 0; i < methodCount; i++)
            {
                writer.PushIdent();
                Method method = intr.Methods[i];
                string comma = i < methodCount - 1 ? "," : "";
                writer.Write(GenerateMethod(intr, method).Trim());
                writer.WriteLineNoIdent(comma);
                writer.WriteLine();
                writer.PopIdent();
            }
 
            writer.WriteLine("}");
            writer.PopIdent();
            writer.WriteLine("})");
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:25,代码来源:AngularGenerator.cs

示例6: Main

        static void Main(string[] args)
        {
            if (string.IsNullOrEmpty(args[0])) throw new Exception("No file name");

            string inputFile = args[0];
            string outputFile = GetOutputFilePath(inputFile);

            Parser p = new Parser(inputFile);
            CodeWriter cw = new CodeWriter();

            List<ParsedCommand> parsedCommands = p.Parse();
            List<string> codedCommands = cw.Write(parsedCommands, Path.GetFileNameWithoutExtension(inputFile));

            File.WriteAllLines(outputFile, codedCommands.ToArray());
        }
开发者ID:prec,项目名称:nand2tetris,代码行数:15,代码来源:Program.cs

示例7: GenerateSqlCreate

        public override string GenerateSqlCreate(Table table)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLineFormat("create table [{0}].[{1}](", table.Schema.Name, table.Name);
            writer.PushIdent();
            int colCount = table.Columns.Count;
            int conCount = table.Constraints.Count;
            for (int i = 0; i < colCount; i++)
            {
                Column col = table.Columns[i];
                DataType dt = TypeMap == null ? col.DataType : TypeMap.MapDataType(col.DataType);
                string nullDef = col.IsNullable? "null": "not null";
                string autoIncrementDef = col.IsAutoIncremented ? "identity(1, 1)" : "";
                string colDef = string.Format("[{0}] {1} {2} {3}", col.Name, dt.FullName, nullDef, autoIncrementDef).Trim();
                string comma = (i < colCount - 1 || conCount > 0) ? "," : "";
                writer.WriteLineFormat("{0}{1}", colDef, comma);
            }

            
            for (int i = 0; i < conCount; i++)
            {
                TableConstraint con = table.Constraints[i];
                string conDef = null;
                if (con.Type == ConstraintType.PrimaryKey)
                {
                    string colDef = StringUtils.GenerateCommaSeparatedString(con.Columns, "[", "]");
                    conDef = string.Format("constraint [{0}] primary key({1})", con.Name, colDef);
                }
                else if (con.Type == ConstraintType.Unique)
                {
                    string colDef = StringUtils.GenerateCommaSeparatedString(con.Columns, "[", "]");
                    conDef = string.Format("constraint [{0}] unique({1})", con.Name, colDef);
                }
                else if (con.Type == ConstraintType.Check)
                {
                    CheckConstraint chk = (CheckConstraint)con;
                    conDef = string.Format("constraint [{0}] check {1}", chk.Name, chk.Clause);
                }
                else if (con.Type == ConstraintType.ForeignKey)
                {
                    ForeignKeyConstraint fk = (ForeignKeyConstraint)con;
                    string colDef = StringUtils.GenerateCommaSeparatedString(fk.Columns, "[", "]");
                    string refColDef = StringUtils.GenerateCommaSeparatedString(fk.ReferencedColumns, "[", "]");
                    conDef = string.Format("constraint [{0}] foreign key({1}) references [{2}].[{3}]({4}) on update {5} on delete {6}", 
                        fk.Name, colDef, con.Table.Schema.Name, fk.ReferencedTable, refColDef, fk.UpdateRule, fk.DeleteRule);
                }
                string comma = i < conCount - 1 ? "," : "";
                writer.WriteLineFormat("{0}{1}", conDef, comma);
            }

            writer.PopIdent();
            writer.Write(")");
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:54,代码来源:SqlServerDatabaseGenerator.cs

示例8: GenerateStoredProcedureCreate

 public override string GenerateStoredProcedureCreate(StoredProcedure storedProcedure)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLineFormat("CREATE PROCEDURE [{0}].[{1}]", storedProcedure.Schema.Name, storedProcedure.Name);
     int paramCount = storedProcedure.Parameters.Count;
     if (paramCount > 0)
     {
         writer.WriteLine("(");
     }
     writer.PushIdent();
     for (int i = 0; i < paramCount; i++)
     {
         Parameter parameter = storedProcedure.Parameters[i];
         DataType dt = TypeMap == null ? parameter.DataType : TypeMap.MapDataType(parameter.DataType);
         string modeDef = parameter.Mode == "OUT" ? parameter.Mode : "";
         string paramName = parameter.Name.StartsWith("@") ? parameter.Name : "@" + parameter.Name;
         string pDef = string.Format("{0} {1} {2}", paramName, dt.FullName, modeDef).Trim();
         string comma = i < paramCount - 1 ? "," : "";
         writer.WriteLineFormat("{0}{1}", pDef, comma);
     }
     writer.PopIdent();
     if (paramCount > 0)
     {
         writer.WriteLine(")");
     }
     writer.WriteLine("as");
     writer.WriteLine("begin");
     writer.PushIdent();
     writer.WriteLine(storedProcedure.Definition);
     writer.PopIdent();
     writer.Write("end");
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:33,代码来源:SqlServerDatabaseGenerator.cs

示例9: GenerateSqlCreate

        public override string GenerateSqlCreate(Table table)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine("DELIMITER $$");
            writer.WriteLineFormat("create table `{0}`.`{1}`(", table.Schema.Name, table.Name);
            writer.PushIdent();
            int colCount = table.Columns.Count;
            int conCount = table.Constraints.Where(c => c.Type != ConstraintType.Check).Count();
            for (int i = 0; i < colCount; i++)
            {
                Column col = table.Columns[i];
                DataType dt = TypeMap == null ? col.DataType : TypeMap.MapDataType(col.DataType);
                string nullDef = col.IsNullable? "null": "not null";
                string autoIncrementDef = col.IsAutoIncremented ? "auto_increment" : "";
                string colDef = string.Format("`{0}` {1} {2} {3}", col.Name, dt.FullName, nullDef, autoIncrementDef).Trim();
                string comma = (i < colCount - 1 || conCount > 0) ? "," : "";
                writer.WriteLineFormat("{0}{1}", colDef, comma);
            }

            
            for (int i = 0; i < conCount; i++)
            {
                TableConstraint con = table.Constraints[i];
                string conDef = null;
                if (con.Type == ConstraintType.PrimaryKey)
                {
                    string colDef = StringUtils.GenerateCommaSeparatedString(con.Columns, "`", "`");
                    conDef = string.Format("constraint `{0}` primary key({1})", con.Name, colDef);
                }
                else if (con.Type == ConstraintType.Unique)
                {
                    string colDef = StringUtils.GenerateCommaSeparatedString(con.Columns, "`", "`");
                    conDef = string.Format("constraint `{0}` unique({1})", con.Name, colDef);
                }
                else if (con.Type == ConstraintType.ForeignKey)
                {
                    ForeignKeyConstraint fk = (ForeignKeyConstraint)con;
                    string colDef = StringUtils.GenerateCommaSeparatedString(fk.Columns, "`", "`");
                    string refColDef = StringUtils.GenerateCommaSeparatedString(fk.ReferencedColumns, "`", "`");
                    conDef = string.Format("constraint `{0}` foreign key({1}) references `{2}`.`{3}`({4}) on update {5} on delete {6}", 
                        fk.Name, colDef, con.Table.Schema.Name, fk.ReferencedTable, refColDef, fk.UpdateRule, fk.DeleteRule);
                }
                string comma = i < conCount - 1 ? "," : "";
                writer.WriteLineFormat("{0}{1}", conDef, comma);
            }

            writer.PopIdent();
            writer.Write(")$$");
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:50,代码来源:MySqlDatabaseGenerator.cs

示例10: GenerateStoredProcedureCreate

 public override string GenerateStoredProcedureCreate(StoredProcedure storedProcedure)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLine("DELIMITER $$");
     writer.WriteLineFormat("create procedure `{0}`.`{1}`(", storedProcedure.Schema.Name, storedProcedure.Name);
     writer.PushIdent();
     int paramCount = storedProcedure.Parameters.Count;
     for (int i = 0; i < paramCount; i++)
     {
         Parameter parameter = storedProcedure.Parameters[i];
         DataType dt = TypeMap == null ? parameter.DataType : TypeMap.MapDataType(parameter.DataType);
         string modeDef = parameter.Mode;// != "IN" ? parameter.Mode : "";
         string pDef = string.Format("{0} {1} {2}", modeDef, parameter.Name.Replace("@", ""), dt.FullName).Trim();
         string comma = i < paramCount - 1 ? "," : "";
         writer.WriteLineFormat("{0}{1}", pDef, comma);
     }
     writer.PopIdent();
     writer.WriteLine(")");
     writer.WriteLine("begin");
     writer.PushIdent();
     writer.WriteLine(storedProcedure.Definition);
     writer.PopIdent();
     writer.Write("end$$");
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:25,代码来源:MySqlDatabaseGenerator.cs

示例11: SaveContent

 /// <summary>
 /// Saves the file contents to disk.
 /// </summary>
 internal override void SaveContent(CodeWriter writer, byte[] contentToSave)
 {
     writer.Write(contentToSave);
 }
开发者ID:Zyphrax,项目名称:PixelCryptor,代码行数:7,代码来源:PFileComet.cs


注:本文中的CodeWriter.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。