本文整理汇总了C#中CodeWriter.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# CodeWriter.WriteLine方法的具体用法?C# CodeWriter.WriteLine怎么用?C# CodeWriter.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeWriter
的用法示例。
在下文中一共展示了CodeWriter.WriteLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteClassHeader
public override void WriteClassHeader(CodeWriter writer, DbLinq.Schema.Dbml.Table table, GenerationContext context)
{
using (writer.WriteRegion(string.Format("{0} handling", typeof(INotifyPropertyChanging).Name)))
{
const string eventName = "PropertyChanging"; // do not change, part of INotifyPropertyChanging
const string emptyArgs = "emptyChangingEventArgs";
// event
writer.WriteEvent(SpecificationDefinition.Public, eventName, typeof(PropertyChangingEventHandler).Name);
writer.WriteLine();
// empty event arg
writer.WriteField(SpecificationDefinition.Private | SpecificationDefinition.Static,
writer.GetAssignmentExpression(emptyArgs, writer.GetNewExpression(
writer.GetMethodCallExpression(typeof(PropertyChangingEventArgs).Name, "\"\""))),
typeof(PropertyChangingEventArgs).Name);
// method
using (writer.WriteMethod(SpecificationDefinition.Protected | SpecificationDefinition.Virtual,
sendPropertyChangingMethod, null))
{
using (writer.WriteIf(writer.GetDifferentExpression(eventName, writer.GetNullExpression())))
{
writer.WriteLine(writer.GetStatement(writer.GetMethodCallExpression(eventName,
writer.GetThisExpression(), emptyArgs)));
}
}
}
}
示例2: 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;
}
示例3: 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;
}
示例4: GenerateClassSerializer
public static void GenerateClassSerializer(ProtoMessage m, CodeWriter cw)
{
if (m.OptionExternal || m.OptionType == "interface")
{
//Don't make partial class of external classes or interfaces
//Make separate static class for them
cw.Bracket(m.OptionAccess + " static class " + m.SerializerType);
}
else
{
cw.Attribute("System.Serializable()");
cw.Bracket(m.OptionAccess + " partial " + m.OptionType + " " + m.SerializerType);
}
GenerateReader(m, cw);
GenerateWriter(m, cw);
foreach (ProtoMessage sub in m.Messages.Values)
{
cw.WriteLine();
GenerateClassSerializer(sub, cw);
}
cw.EndBracket();
cw.WriteLine();
return;
}
示例5: GenerateFileFooter
private static void GenerateFileFooter(StreamWriter file, CodeWriter writer)
{
writer.Indent--;
writer.WriteLine("}"); // end of test type
writer.Indent--;
writer.WriteLine("}"); // namesapce
file.Close();
}
示例6: 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;
}
示例7: GenerateTables
public override string GenerateTables(Schema schema)
{
CodeWriter writer = new CodeWriter();
foreach(Table table in schema.Tables)
{
writer.WriteLineFormat("-- {0} --", table.Name);
writer.WriteLine(GenerateSqlCreate(table));
writer.WriteLine();
}
return writer.Code;
}
示例8: 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;
}
示例9: GenerateEnum
public static void GenerateEnum(ProtoEnum me, CodeWriter cw)
{
cw.Bracket("public enum " + me.CsType);
foreach (var epair in me.Enums)
{
cw.Summary(epair.Comment);
cw.WriteLine(epair.Name + " = " + epair.Value + ",");
}
cw.EndBracket();
cw.WriteLine();
}
示例10: GenerateStoredProcedures
public override string GenerateStoredProcedures(Schema schema)
{
CodeWriter writer = new CodeWriter();
foreach (StoredProcedure sp in schema.StoredProcedures)
{
writer.WriteLineFormat("-- {0} --", sp.Name);
sp.Definition = DUMMY_BODY;
writer.WriteLine(GenerateStoredProcedureCreate(sp));
writer.WriteLine();
}
return writer.Code;
}
示例11: GenerateCheck
private static void GenerateCheck(CodeWriter writer, string typeName)
{
var helperName = "Check" + typeName;
writer.WriteLine("public void {0}({1} value, string format)", helperName, typeName);
writer.WriteLine("{");
writer.WriteLine(" var parsed = Format.Parse(format);");
writer.WriteLine(" formatter.Clear();");
writer.WriteLine(" formatter.Append(value, parsed);");
writer.WriteLine(" var result = formatter.ToString();");
writer.WriteLine(" var clrResult = value.ToString(format, CultureInfo.InvariantCulture);");
writer.WriteLine(" Assert.Equal(clrResult, result);");
writer.WriteLine("}");
writer.WriteLine("");
}
示例12: GenerateProperties
/// <summary>
/// Generates the properties.
/// </summary>
/// <param name='template'>
/// if true it will generate only properties that are not included by default, because of the [generate=false] option.
/// </param>
static void GenerateProperties(ProtoMessage m, CodeWriter cw)
{
foreach (Field f in m.Fields.Values)
{
if (f.OptionExternal)
cw.WriteLine("//" + GenerateProperty(f) + " // Implemented by user elsewhere");
else
{
if (f.Comments != null)
cw.Summary(f.Comments);
cw.WriteLine(GenerateProperty(f));
cw.WriteLine();
}
}
//Wire format field ID
#if DEBUG
cw.Comment("ProtocolBuffers wire field id");
foreach (Field f in m.Fields.Values)
{
cw.WriteLine("public const int " + f.CsName + "FieldID = " + f.ID + ";");
}
#endif
}
示例13: generateInsertBody
private string generateInsertBody(Table table, List<Column> insertableColumns)
{
List<string> colNames = new List<string>();
foreach (Column col in insertableColumns)
{
colNames.Add(col.Name);
}
CodeWriter writer = new CodeWriter();
writer.WriteLineFormat("INSERT INTO [{0}].[{1}]", table.Schema.Name, table.Name);
writer.WriteLineFormat("({0})", StringUtils.GenerateCommaSeparatedString(colNames, "[", "]"));
writer.WriteLine("VALUES");
writer.WriteLineFormat("({0});", StringUtils.GenerateCommaSeparatedString(colNames, "@", ""));
writer.WriteLine("RETURN SCOPE_IDENTITY();");
return writer.Code;
}
示例14: WriteClass
protected virtual void WriteClass(CodeWriter writer, Table table, Database schema, GenerationContext context)
{
writer.WriteLine();
string entityBase = context.Parameters.EntityBase;
if (string.IsNullOrEmpty(entityBase))
entityBase = schema.EntityBase;
var specifications = SpecificationDefinition.Partial;
if (table.Type.AccessModifierSpecified)
specifications |= GetSpecificationDefinition(table.Type.AccessModifier);
else
specifications |= SpecificationDefinition.Public;
if (table.Type.ModifierSpecified)
specifications |= GetSpecificationDefinition(table.Type.Modifier);
var tableAttribute = NewAttributeDefinition<TableAttribute>();
tableAttribute["Name"] = table.Name;
using (writer.WriteAttribute(tableAttribute))
using (writer.WriteClass(specifications,
table.Type.Name, entityBase, context.Parameters.EntityInterfaces))
{
WriteClassHeader(writer, table, context);
WriteCustomTypes(writer, table, schema, context);
WriteClassExtensibilityDeclarations(writer, table, context);
WriteClassProperties(writer, table, context);
if (context.Parameters.GenerateEqualsHash)
WriteClassEqualsAndHash(writer, table, context);
WriteClassChildren(writer, table, schema, context);
WriteClassParents(writer, table, schema, context);
WriteClassChildrenAttachment(writer, table, schema, context);
WriteClassCtor(writer, table, schema, context);
}
}
示例15: WriteDataContextProcedure
private void WriteDataContextProcedure(CodeWriter writer, Function procedure, GenerationContext context)
{
if (procedure == null || procedure.Name == null)
{
//Logger.Write(Level.Error, "CodeGenStoredProc: Error L33 Invalid storedProcedure object");
writer.WriteCommentLine("error L33 Invalid storedProcedure object");
return;
}
var functionAttribute = NewAttributeDefinition<FunctionAttribute>();
functionAttribute["Name"] = procedure.Name;
functionAttribute["IsComposable"] = procedure.IsComposable;
SpecificationDefinition specifications;
if (procedure.AccessModifierSpecified)
specifications = GetSpecificationDefinition(procedure.AccessModifier);
else
specifications = SpecificationDefinition.Public;
if (procedure.ModifierSpecified)
specifications |= GetSpecificationDefinition(procedure.Modifier);
using (writer.WriteAttribute(functionAttribute))
using (writer.WriteMethod(specifications, GetProcedureName(procedure),
GetProcedureType(procedure), GetProcedureParameters(procedure)))
{
string result = WriteProcedureBodyMethodCall(writer, procedure, context);
WriteProcedureBodyOutParameters(writer, procedure, result, context);
WriteProcedureBodyReturnValue(writer, procedure, result, context);
}
writer.WriteLine();
}