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


C# CodeWriter.PopIdent方法代码示例

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


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

示例1: GenerateClass

        public string GenerateClass(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine(HEADER);
            writer.WriteLineFormat("package {0}", service.Name);
            writer.WriteLine("{");
            writer.PushIdent();
            writer.WriteLine(IMPORT);
            writer.WriteLine();
            writer.WriteLineFormat("public class {0}Client", intr.Name);
            writer.WriteLine("{");
            writer.PushIdent();
            writer.WriteLine("public var url: String = \"\";");
            writer.WriteLine(LOAD);
            writer.WriteLine();

            foreach(Method method in intr.Methods)
            {
                writer.WriteLine(GenerateMethodHeader(intr, method));
                writer.WriteLine("{"); 
                writer.PushIdent();
                writer.WriteLine(GenerateMethodBody(intr, method));
                writer.PopIdent();
                writer.WriteLine("}");
                writer.WriteLine();
            }
            writer.PopIdent();
            writer.WriteLine("}");
            writer.PopIdent();
            writer.WriteLine("}");
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:32,代码来源:FlexGenerator.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: 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

示例4: generateUpdateBody

        private string generateUpdateBody(Table table, List<Column> keyColumns, List<Column> updateColumns)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLineFormat("UPDATE [{0}].[{1}]", table.Schema.Name, table.Name);
            writer.WriteLine("SET");
            writer.PushIdent();
            for (int i = 0; i < updateColumns.Count; i++)
            {
                Column column = updateColumns[i];
                string and = i < updateColumns.Count - 1 ? "," : "";
                string cond = string.Format("[{0}] = @{0} {1}", column.Name, and).Trim();
                writer.WriteLine(cond);
            }
            writer.PopIdent();

            writer.WriteLine("WHERE");
            writer.PushIdent();
            for (int i = 0; i < keyColumns.Count; i++)
            {
                Column column = keyColumns[i];
                string and = i < keyColumns.Count - 1 ? "AND" : "";
                string cond = string.Format("[{0}] = @{0} {1}", column.Name, and).Trim();
                writer.WriteLine(cond);
            }
            writer.PopIdent();
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:27,代码来源:SqlServerCrudGenerator.cs

示例5: GenerateClass

 public override string GenerateClass(Schema schema)
 {
     CodeWriter writer = new CodeWriter();
     string className = "DataStore";
     writer.WriteLine(USING_STRING);
     writer.WriteLine();
     writer.WriteLine("namespace DataAccess");
     writer.WriteLine("{");
     writer.PushIdent();
     writer.WriteLineFormat("public class {0}: DatabaseContext, IDataStore", className);
     writer.WriteLine("{");
     writer.PushIdent();
     writer.WriteLineFormat("public {0}(IDbConnection connection, IDbTransaction transaction) : base(connection, transaction) {{ }}", className);
     writer.WriteLineFormat("public {0}(IDbConnection connection) : base(connection, null) {{ }}", className);
     writer.WriteLine();
     
     foreach (StoredProcedure sp in schema.StoredProcedures)
     {
         string methodHeader = "public " + generateMethodHeader(sp);
         string methodBody = GenerateMethodBody(sp);
         writer.WriteLine(methodHeader);
         writer.WriteLine(methodBody);
         writer.WriteLine();
     }
     writer.PopIdent();
     writer.WriteLine("}");
     writer.PopIdent();
     writer.WriteLine("}");
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:30,代码来源:CSharpDataAccessGenerator.cs

示例6: GenerateDropIfExists

 private string GenerateDropIfExists(string spName)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLineFormat("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{0}') AND type in (N'P', N'PC'))", spName);
     writer.PushIdent();
     writer.WriteLineFormat("DROP PROCEDURE {0};", spName);
     writer.PopIdent();
     writer.WriteLine("GO");
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:10,代码来源:SqlServerCrudGenerator.cs

示例7: 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

示例8: GenerateInterface

 public override string GenerateInterface(Schema schema)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLine(USING_STRING);
     writer.WriteLine();
     writer.WriteLine("namespace DataAccess");
     writer.WriteLine("{");
     writer.PushIdent();
     writer.WriteLine("public interface IDataStore");
     writer.WriteLine("{");
     writer.PushIdent();
     foreach (StoredProcedure sp in schema.StoredProcedures)
     {
         string methodHeader = generateMethodHeader(sp) + ";";
         writer.WriteLine(methodHeader);
     }
     writer.PopIdent();
     writer.WriteLine("}");
     writer.PopIdent();
     writer.WriteLine("}");
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:22,代码来源:CSharpDataAccessGenerator.cs

示例9: generateDeleteBody

 public string generateDeleteBody(Table table, List<Column> keyColumns)
 {
     CodeWriter writer = new CodeWriter();
     writer.WriteLineFormat("DELETE FROM [{0}].[{1}]", table.Schema.Name, table.Name);
     writer.WriteLine("WHERE");
     writer.PushIdent();
     for (int i = 0; i < keyColumns.Count; i++)
     {
         Column column = keyColumns[i];
         string and = i < keyColumns.Count - 1 ? "and" : "";
         string cond = string.Format("[{0}] = @{0} {1}", column.Name, and).Trim();
         writer.WriteLine(cond);
     }
     writer.PopIdent();
     return writer.Code;
 }
开发者ID:kumait,项目名称:HXF.net,代码行数:16,代码来源:SqlServerCrudGenerator.cs

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: GenerateClientClass

        public string GenerateClientClass(Service service, Interface intr)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine(HEADER);
            writer.WriteLineFormat("package {0};", service.Name);
            writer.WriteLine(IMPORT);
            writer.WriteLine();
            string className = intr.Name + "Client";
            writer.WriteLineFormat("public class {0}", className);
            writer.WriteLine("{");
            writer.PushIdent();
            writer.WriteLine("private static final String SERVICE_URL = \"\";");
            writer.WriteLine("private static final int BUFFER_SIZE = 4096;");
            writer.WriteLine();
            writer.WriteLine(LOAD_METHOD);
            writer.WriteLine();
            writer.WriteLine(MAP_OBJECT_METHOD);
            writer.WriteLine();
            writer.WriteLine(CONVERT_METHOD);
            writer.WriteLine();

            foreach (Method method in intr.Methods)
            {
                writer.WriteLine(GenerateMethod(intr, method));
                writer.WriteLine();
            }
            writer.PopIdent();
            writer.WriteLine("}");
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:30,代码来源:JavaGenerator.cs

示例15: GenerateMethodBody

        private string GenerateMethodBody(StoredProcedure sp)
        {
            CodeWriter writer = new CodeWriter();
            writer.WriteLine("{");
            writer.PushIdent();
            writer.WriteLine("List<IDbDataParameter> parameters = null;");
            if (sp.Parameters.Count > 0)
            {
                writer.WriteLine("parameters = new List<IDbDataParameter>();");
                writer.WriteLine("IDbCommand cmd = connection.CreateCommand();");
                writer.WriteLine("if (this.transaction != null)");
                writer.WriteLine("{");
                writer.PushIdent();
                writer.WriteLine("cmd.Transaction = this.transaction;");
                writer.PopIdent();
                writer.WriteLine("}");
            }

            IEnumerable<Parameter> inParameters = sp.Parameters.Where<Parameter>(p => p.Mode.ToLower() == "in" || p.Mode.ToLower() == "inout");

            foreach (Parameter p in sp.Parameters)
            {
                string pname = p.Name.Replace("@", "");
                if (hasNamingAdapter)
                {
                    pname = Options.NamingAdapter.GetParameterName(pname);
                }
                writer.WriteLineFormat("IDbDataParameter p{0} = cmd.CreateParameter();", pname);
                writer.WriteLineFormat("p{0}.ParameterName = \"{1}\";", pname, p.Name);
                if (p.Mode.ToLower() == "in" || p.Mode.ToLower() == "inout")
                {
                    writer.WriteLineFormat("p{0}.Value = ({0} == null)? (object)DBNull.Value : {0};", pname);
                }
                string mode = p.Mode.ToLower();
                string pDirection = mode == "in" ? "ParameterDirection.Input" : mode == "out" ? "ParameterDirection.Output" : "ParameterDirection.InputOutput";
                writer.WriteLineFormat("p{0}.Direction = {1};", pname, pDirection);
                writer.WriteLineFormat("parameters.Add(p{0});", pname);
                writer.WriteLine();
            }

            string namingAdapterName = "";
            if (Options != null && Options.NamingAdapter != null)
            {
                namingAdapterName = this.Options.NamingAdapter.GetType().Name;
            }
            else
            {
                namingAdapterName = "SameNamingAdapter";
            }
            writer.WriteLineFormat("StoredProcResult result = ExecProc(\"{0}\", parameters, new {1}(), {2}, resultTypes);", sp.Name, namingAdapterName, Options.SupportsReturnValue.ToString().ToLower() );

            IEnumerable<Parameter> outParameters = sp.Parameters.Where<Parameter>(p => p.Mode.ToLower() == "out" || p.Mode.ToLower() == "inout");

            int index = 0;
            foreach (Parameter p in outParameters)
            {
                string pname = p.Name.Replace("@", "");
                if (hasNamingAdapter)
                {
                    pname = Options.NamingAdapter.GetParameterName(pname);
                }
                string ptype = TypeMap == null ? p.DataType.Name : TypeMap.MapDataType(p.DataType).Name;
                writer.WriteLineFormat("{0} = ({1})result.OutPramaters.ElementAt<IDbDataParameter>({2}).Value;", pname, ptype, index);
                index++;
            }
            writer.WriteLine();
            
            writer.WriteLine("return result;");
            writer.PopIdent();
            writer.WriteLine("}");
            return writer.Code;
        }
开发者ID:kumait,项目名称:HXF.net,代码行数:72,代码来源:CSharpDataAccessGenerator.cs


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