本文整理汇总了C#中System.CodeDom.Compiler.IndentedTextWriter.WriteGeneratedCodeAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IndentedTextWriter.WriteGeneratedCodeAttribute方法的具体用法?C# IndentedTextWriter.WriteGeneratedCodeAttribute怎么用?C# IndentedTextWriter.WriteGeneratedCodeAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CodeDom.Compiler.IndentedTextWriter
的用法示例。
在下文中一共展示了IndentedTextWriter.WriteGeneratedCodeAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteValueProperty
static void WriteValueProperty(ColumnModel column, IndentedTextWriter writer)
{
writer.WriteLine(@"///<summary>" + column.Description.EscapeXml() + @"</summary>");
writer.WriteGeneratedCodeAttribute();
writer.WriteLine(column.PropertyVisibility.ToString().ToLowerInvariant() + " " + column.ActualType + " " + column.PropertyName + " {");
writer.Indent++;
writer.WriteLine("get { return base.Field<" + column.ActualType + ">(" + column.ColumnPropertyName + "); }");
if (string.IsNullOrEmpty(column.Expression))
writer.WriteLine("set { base[" + column.ColumnPropertyName + "] = value; }");
writer.Indent--;
writer.WriteLine("}");
}
示例2: WriteSchema
static void WriteSchema(SchemaModel schema, IndentedTextWriter writer)
{
writer.WriteLine(@"///<summary>" + schema.RowClassDescription.EscapeXml() + @"</summary>");
writer.WriteLine(schema.RowClassVisibility.ToString().ToLowerInvariant() + " partial class " + schema.RowClassName + " : Row {");
writer.Indent++;
writer.WriteLine(@"///<summary>Creates a new " + schema.RowClassName.EscapeXml() + @" instance.</summary>");
writer.WriteLine("public " + schema.RowClassName + " () : base(Schema) { Initialize(); }");
writer.WriteLine("partial void Initialize();");
writer.WriteLine();
writer.WriteLine(@"///<summary>Creates a strongly-typed " + schema.Name.EscapeXml() + @" table.</summary>");
writer.WriteLine("public static TypedTable<" + schema.RowClassName + "> CreateTable() "
+ "{ return new TypedTable<" + schema.RowClassName + ">(Schema, () => new " + schema.RowClassName + "()); }");
writer.WriteLine();
foreach (var column in schema.Columns) {
writer.WriteLine(@"///<summary>Gets the schema's " + column.Name.EscapeXml() + @" column.</summary>");
writer.WriteLine("public static " + column.ColumnType.Name + " " + column.ColumnPropertyName + " { get; private set; }");
}
writer.WriteLine();
writer.WriteLine(@"///<summary>Gets the " + schema.Name.EscapeXml() + @" schema instance.</summary>");
writer.WriteLine("public static new TypedSchema<" + schema.RowClassName + "> Schema { get; private set; }");
writer.WriteLine(@"///<summary>Gets the SchemaMapping that maps this schema to the SQL Server " + schema.SqlName.EscapeXml() + @" table.</summary>");
writer.WriteLine("public static SchemaMapping SchemaMapping { get; private set; }");
writer.WriteLine();
writer.WriteGeneratedCodeAttribute();
writer.WriteLine("static " + schema.RowClassName + "() {");
writer.Indent++;
writer.WriteLine("#region Create Schema");
writer.WriteLine("Schema = new TypedSchema<" + schema.RowClassName + ">(" + schema.Name.Quote() + ");");
foreach (var column in schema.Columns) {
writer.WriteLine();
WriteColumnCreation(column, writer);
}
writer.WriteLine("#endregion");
writer.WriteLine();
writer.WriteLine("#region Create SchemaMapping");
writer.WriteLine("SchemaMapping = new SchemaMapping(Schema, false);");
writer.WriteLine("SchemaMapping.SqlName = " + schema.SqlName.Quote() + ";");
writer.WriteLine("SchemaMapping.SqlSchemaName = " + schema.SqlSchemaName.Quote() + ";");
writer.WriteLine();
foreach (var column in schema.Columns.Where(c => c.GenerateSqlMapping))
writer.WriteLine("SchemaMapping.Columns.AddMapping(" + column.PropertyName + "Column, " + column.SqlName.Quote() + ");");
writer.WriteLine("#endregion");
writer.WriteLine("SchemaMapping.SetPrimaryMapping(SchemaMapping);");
writer.Indent--;
writer.WriteLine("}");
writer.WriteLine();
writer.WriteLine(@"///<summary>Gets the typed table that contains this row, if any.</summary>");
writer.WriteGeneratedCodeAttribute();
writer.WriteLine("public new TypedTable<" + schema.RowClassName + "> Table { get { return (TypedTable<" + schema.RowClassName + ">)base.Table; } }");
writer.WriteLine("#region Value Properties");
foreach (var column in schema.Columns)
WriteValueProperty(column, writer);
writer.WriteLine("#endregion");
if (schema.ChildSchemas.Any()) {
writer.WriteLine();
writer.WriteLine("#region ChildRows Properties");
//Support schemas with two foreign keys
//that reference the same parent schema
foreach (var foreignColumn in schema.ChildSchemas.Distinct().SelectMany(fs => fs.Columns.Where(c => c.ForeignSchema == schema))) {
//Example:
//public IChildRowCollection<Pledge> Pledges { get { return TypedChildRows<Pledge>(Pledge.PersonIdColumn); } }
writer.WriteLine(@"///<summary>" + foreignColumn.ForeignRelationPropertyDescription.EscapeXml() + @"</summary>");
writer.WriteLine(foreignColumn.Owner.RowClassVisibility.ToString().ToLowerInvariant()
+ " IChildRowCollection<" + foreignColumn.Owner.RowClassName + "> " + foreignColumn.ForeignRelationPropertyName
+ " { get { return TypedChildRows<" + foreignColumn.Owner.RowClassName + ">(" + foreignColumn.Owner.RowClassName + "." + foreignColumn.PropertyName + "Column); } }");
}
writer.WriteLine("#endregion");
}
writer.WriteLine();
writer.WriteLine("#region Partial Methods");
writer.WriteLine("partial void OnColumnChanged(Column column, object oldValue, object newValue);");
foreach (var column in schema.Columns.NonCalculated()) {
writer.WriteLine();
WriteColumnPartials(column, writer);
}
writer.WriteLine("#endregion");
writer.WriteLine();
writer.WriteLine("#region Column Callbacks");
#region ValidateValue
writer.WriteLine(@"///<summary>Checks whether a value would be valid for a given column in an attached row.</summary>");
//.........这里部分代码省略.........