public virtual void WriteCodeToAccessSetting(TextWriter writer, int numTabs, int versionArrayIndex) { StringBuilder builder = new StringBuilder(); AccessModifier defaultScope; // Start the property if ((TooltipDocumentation != null) && (TooltipDocumentation.Length > 0)) { GameSettingsGenerator.WriteTooltipComment(writer, numTabs, TooltipDocumentation); } numTabs = GameSettingsGenerator.WriteStartEncapsulation(writer, numTabs, GetCodeForPropertyDeclaration(builder, out defaultScope)); // Check if we should write the getter GeneratePropertyEventArgs args = new GeneratePropertyEventArgs(writer, numTabs, GetCodeToInstance(builder, versionArrayIndex, true), versionArrayIndex); if (GetterScope != AccessModifier.None) { WriteCodeForGetter(args, builder, defaultScope); } // Check if we should write the setter if (SetterScope != AccessModifier.None) { WriteCodeForSetter(args, builder, defaultScope); } // End the property numTabs = GameSettingsGenerator.WriteEndEncapsulation(writer, numTabs); }
protected void WriteCodeForSetter(StreamWriter writer, int numTabs, StringBuilder builder, AccessModifier defaultScope, int versionArrayIndex) { builder.Length = 0; // Start set if (SetterScope != defaultScope) { AppendScopeToStringBuilder(builder, SetterScope); } builder.Append("set"); numTabs = GameSettingsGenerator.WriteStartEncapsulation(writer, numTabs, builder.ToString()); // Write value GameSettingsGenerator.WriteTabs(writer, numTabs); if (CanWriteCodeToInstance == true) { // Write return WriteCodeToInstance(writer, versionArrayIndex, true); writer.Write('.'); writer.Write(SetterCode); writer.WriteLine(';'); } else { // Otherwise, plop the getter code directly writer.WriteLine(SetterCode); } // End the property GameSettingsGenerator.WriteEndEncapsulation(writer, numTabs); }
public virtual void WriteCodeToAccessSetting(StreamWriter writer, int numTabs, int versionArrayIndex) { StringBuilder builder = new StringBuilder(); AccessModifier defaultScope; // Start the property if ((TooltipDocumentation != null) && (TooltipDocumentation.Length > 0)) { GameSettingsGenerator.WriteTooltipComment(writer, numTabs, TooltipDocumentation); } numTabs = GameSettingsGenerator.WriteStartEncapsulation(writer, numTabs, GetCodeForPropertyDeclaration(builder, out defaultScope)); // Check if we should write the getter if ((GetterScope != AccessModifier.None) && (string.IsNullOrEmpty(GetterCode) == false)) { WriteCodeForGetter(writer, numTabs, builder, defaultScope, versionArrayIndex); } // Check if we should write the setter if ((SetterScope != AccessModifier.None) && (string.IsNullOrEmpty(SetterCode) == false)) { WriteCodeForSetter(writer, numTabs, builder, defaultScope, versionArrayIndex); } // End the property numTabs = GameSettingsGenerator.WriteEndEncapsulation(writer, numTabs); }
protected void WriteCodeForSetter(GeneratePropertyEventArgs args, StringBuilder builder, AccessModifier defaultScope) { builder.Clear(); // Start set if (SetterScope != defaultScope) { AppendScopeToStringBuilder(builder, SetterScope); } builder.Append("set"); args.numTabs = GameSettingsGenerator.WriteStartEncapsulation(args.writer, args.numTabs, builder.ToString()); // Write instance SetterCode?.Invoke(this, args); // End the property args.numTabs = GameSettingsGenerator.WriteEndEncapsulation(args.writer, args.numTabs); }
public void AutoGenerateSettingsCode() { // First grab all the versions VersionGeneratorArgs versionsArgs = GameSettingsGenerator.GetAllVersions(); // Setup namespaces and arguments int index = 0; NamespaceGeneratorArgs usingsArgs = new NamespaceGeneratorArgs(); SettingsGeneratorArgs settingsArgs = new SettingsGeneratorArgs(); foreach (ISettingsVersionGenerator version in versionsArgs) { version.UpdateNamespaceArgs(usingsArgs); version.UpdateSettingArgs(index, settingsArgs); ++index; } // Next, write to a file GameSettingsGenerator.WriteCode(versionsArgs, usingsArgs, settingsArgs); }
/// <summary> /// Writes the default constructor of this decorator. /// </summary> public virtual void WriteCodeForConstructor(StreamWriter writer, int numTabs) { GameSettingsGenerator.WriteStartOfLine(writer, numTabs, "new "); writer.Write(GetType()); writer.Write("()"); }
public void WriteTabs() { // Write tabs GameSettingsGenerator.WriteTabs(writer, numTabs); }