private void GenerateDefFile() { HashSet <string> namespaces = new HashSet <string>(); namespaces.Add("Noggolloquy"); foreach (var obj in this.ObjectGenerationsByID.Values) { namespaces.Add(obj.Namespace); } FileGeneration fg = new FileGeneration(); foreach (var nameS in namespaces) { fg.AppendLine($"using {nameS};"); } fg.AppendLine(); fg.AppendLine("namespace Noggolloquy"); using (new BraceWrapper(fg)) { fg.AppendLine($"public class ProtocolDefinition_{this.Definition.Nickname} : IProtocolRegistration"); using (new BraceWrapper(fg)) { fg.AppendLine($"public readonly ProtocolKey ProtocolKey = new ProtocolKey({this.Definition.Key.ProtocolID});"); fg.AppendLine(); fg.AppendLine("public void Register()"); using (new BraceWrapper(fg)) { foreach (var obj in this.ObjectGenerationsByID.Values) { fg.AppendLine("NoggolloquyRegistration.Register("); using (new DepthWrapper(fg)) { fg.AppendLine($"new ObjectKey(ProtocolKey, {obj.ID}, {obj.Version}),"); fg.AppendLine($"new NoggolloquyTypeRegister("); using (new DepthWrapper(fg)) { fg.AppendLine($"classType: typeof({obj.Name}{obj.EmptyGenerics}),"); fg.AppendLine($"fullName: \"{obj.Name}\","); fg.AppendLine($"genericCount: {obj.Generics.Count},"); fg.AppendLine($"objectKey: new ObjectKey(ProtocolKey, {obj.ID}, {obj.Version})));"); } } } } } } fg.Generate( new FileInfo( DefFileLocation.FullName + $"/ProtocolDefinition_{this.Definition.Nickname}.cs")); }