public void Write(string fileName) { using (var writer = new CodeFileWriter(fileName, "WCell.Constants.Updates", "UpdateFields", CodeFileWriter.StaticTag + " " + CodeFileWriter.Class, "", "System")) { writer.ExecuteSafely(() =>{ writer.WriteIndent("public static readonly "); writer.Array(UpdateFieldTypeName, "AllFields", 2, ";", () =>{ for (var i = 0; i < m_fields.Length; i++) { var fieldArr = m_fields[i]; writer.WriteRegion( ((ObjectTypeId) i).ToString()); writer.NewArray("UpdateField", ",", () =>{ foreach ( var field in fieldArr) { if (field != null) { writer. WriteCommentLine( field.FullName); var flags = Utility. GetSetIndicesEnum (field.Flags); var args = new[] { new KeyValuePair < string , object >( "Flags", flags . TransformList (( flag) => "UpdateFieldFlags." + flag) . ToString (" | ")) , new KeyValuePair < string , object >( "Group", "ObjectTypeId." + field . Group) , new KeyValuePair < string , object >( "Name", "\"" + field . Name + "\"") , new KeyValuePair < string , object >( "Offset", field . Offset) , new KeyValuePair < string , object >( "Size", field . Size) , new KeyValuePair < string , object >( "Type", "UpdateFieldType." + field . Type) }; writer.NewInit( UpdateFieldTypeName, args, ","); } else { writer.WriteLine( "null,"); } } }); writer.WriteEndRegion(); writer.WriteLine(); } }); writer.WriteLine(); //writer.WriteStaticMethod("Init", () => { //}); //writer.WriteStaticCTor(() => { // writer.Call("Init"); //}); }); } }
public void Write(string fileName) { using (var writer = new CodeFileWriter(fileName, "WCell.Constants.Updates", "UpdateFields", CodeFileWriter.StaticTag + " " + CodeFileWriter.Class, "", "System")) { writer.ExecuteSafely(() => { writer.WriteIndent("public static readonly "); writer.Array(UpdateFieldTypeName, "AllFields", 2, ";", () => { for (var i = 0; i < m_fields.Length; i++) { var fieldArr = m_fields[i]; writer.WriteRegion(((ObjectTypeId)i).ToString()); writer.NewArray("UpdateField", ",", () => { foreach (var field in fieldArr) { if (field != null) { writer.WriteCommentLine(field.FullName); var flags = Utility.GetSetIndicesEnum(field.Flags); var args = new[] { new KeyValuePair <string, object> ("Flags", flags.TransformList((flag) => "UpdateFieldFlags." + flag) . ToString (" | ")) , new KeyValuePair < string , object >( "Group", "ObjectTypeId." + field . Group) , new KeyValuePair < string , object >( "Name", "\"" + field . Name + "\"") , new KeyValuePair < string , object >( "Offset", field . Offset) , new KeyValuePair < string , object >( "Size", field . Size) , new KeyValuePair < string , object >( "Type", "UpdateFieldType." + field . Type) }; writer.NewInit( UpdateFieldTypeName, args, ","); } else { writer.WriteLine( "null,"); } } }); writer.WriteEndRegion(); writer.WriteLine(); } }); writer.WriteLine(); //writer.WriteStaticMethod("Init", () => { //}); //writer.WriteStaticCTor(() => { // writer.Call("Init"); //}); }); } }