private void GenerateCopy(FileGeneration fg, string accessorPrefix, string rhsAccessorPrefix, string cmdAccessor)
 {
     fg.AppendLine($"{accessorPrefix}.{this.Name}.SetTo(");
     using (new DepthWrapper(fg))
     {
         fg.AppendLine($"{ rhsAccessorPrefix}.{ this.Name}.Select(");
         using (new DepthWrapper(fg))
         {
             fg.AppendLine($"(i) => new KeyValuePair<{this.KeyTypeGen.TypeName}, {this.ValueTypeGen.TypeName}>(");
             using (new DepthWrapper(fg))
             {
                 fg.AppendLine($"i.Key{ (this.KeyIsNogg ? ".Copy())" : string.Empty) },");
                 fg.AppendLine($"i.Value{ (this.ValueIsNogg ? ".Copy())" : string.Empty)})),");
             }
         }
         fg.AppendLine($"{ cmdAccessor});");
     }
 }
Esempio n. 2
0
 protected virtual void GenerateNotifyingCtor(FileGeneration fg)
 {
     fg.AppendLine("protected readonly INotifyingItem<" + TypeName + "> _" + this.Name + " = new NotifyingItem<" + TypeName + ">(");
     using (new DepthWrapper(fg))
     {
         if (HasDefault)
         {
             fg.AppendLine("defaultVal: " + GenerateDefaultValue() + ",");
             fg.AppendLine("markAsSet: false");
         }
         else
         {
             fg.AppendLine("default(" + this.TypeName + "),");
             fg.AppendLine("markAsSet: false");
         }
     }
     fg.AppendLine(");");
 }
Esempio n. 3
0
        public void GenerateInterfaceMembers(FileGeneration fg, string member)
        {
            using (new RegionWrapper(fg, "Interface Members"))
            {
                // Get nth
                fg.AppendLine("public " + ItemTypeName + " GetNth" + this.Name + "(int index)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine("return " + member + "[index];");
                }
                if (this.isNoggSingle)
                {
                    fg.AppendLine($"{GetterTypeName} {this.ObjectGen.Getter_InterfaceStr}.GetNth{this.Name}(int index)");
                    using (new BraceWrapper(fg))
                    {
                        fg.AppendLine("return " + member + "[index];");
                    }
                }

                fg.AppendLine("INotifyingList" + (this.Protected ? "Getter" : string.Empty) + "<" + this.ItemTypeName + "> " + this.ObjectGen.InterfaceStr + "." + this.Name + " { get { return " + member + "; } }");
                fg.AppendLine("INotifyingListGetter<" + this.ItemTypeName + "> " + this.ObjectGen.Getter_InterfaceStr + "." + this.Name + " { get { return " + member + "; } }");
            }
        }
Esempio n. 4
0
 public override void GenerateGetNth(FileGeneration fg, string identifier)
 {
     fg.AppendLine("return " + identifier + "." + this.GetPropertyString(false) + "; ");
 }
 public override void GenerateGetNth(FileGeneration fg, string identifier)
 {
     fg.AppendLine("return " + identifier + "." + this.Name + ";");
 }
 public override void GenerateForInterface(FileGeneration fg)
 {
     fg.AppendLine($"new INotifyingKeyedCollection{(this.Protected ? "Getter" : string.Empty)}<{this.TypeTuple}> {this.Name} {{ get; }}");
 }
 public override void SetMaskException(FileGeneration fg, string errorMaskMemberAccessor, string exception)
 {
     fg.AppendLine($"{errorMaskMemberAccessor}.Overall = {exception};");
 }
Esempio n. 8
0
 public void Dispose()
 {
     fg.AppendLine("#endregion");
 }
        private void GenerateRead(ObjectGeneration obj, FileGeneration fg)
        {
            var param = new XmlReadGenerationParameters()
            {
                Obj          = obj,
                Accessor     = "this",
                FG           = fg,
                Field        = null,
                Name         = "Root",
                XmlNodeName  = "root",
                XmlGen       = this,
                MaskAccessor = "mask"
            };

            if (!obj.Abstract)
            {
                fg.AppendLine($"public static {obj.ObjectName} CreateFromXML(XElement root)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine($"var ret = new {obj.Name}();");
                    fg.AppendLine($"NoggXmlTranslation<{obj.Name}, {obj.GetErrorMaskItemString()}>.Instance.CopyIn(");
                    using (new DepthWrapper(fg))
                    {
                        fg.AppendLine($"root: root,");
                        fg.AppendLine($"item: ret,");
                        fg.AppendLine($"doMasks: false,");
                        fg.AppendLine($"mask: out {obj.GetErrorMaskItemString()} errorMask,");
                        fg.AppendLine($"cmds: null);");
                    }
                    fg.AppendLine("return ret;");
                }
                fg.AppendLine();

                fg.AppendLine($"public static {obj.ObjectName} CreateFromXML(XElement root, out {obj.GetErrorMaskItemString()} errorMask)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine($"var ret = new {obj.Name}();");
                    fg.AppendLine($"NoggXmlTranslation<{obj.Name}, {obj.GetErrorMaskItemString()}>.Instance.CopyIn(");
                    using (new DepthWrapper(fg))
                    {
                        fg.AppendLine($"root: root,");
                        fg.AppendLine($"item: ret,");
                        fg.AppendLine($"doMasks: true,");
                        fg.AppendLine($"mask: out errorMask,");
                        fg.AppendLine($"cmds: null);");
                    }
                    fg.AppendLine("return ret;");
                }
                fg.AppendLine();
            }

            if (obj is StructGeneration)
            {
                return;
            }
            fg.AppendLine("public" + obj.FunctionOverride + "void CopyInFromXML(XElement root, NotifyingFireParameters? cmds = null)");
            using (new BraceWrapper(fg))
            {
                fg.AppendLine($"NoggXmlTranslation<{obj.Name}, {obj.GetErrorMaskItemString()}>.Instance.CopyIn(");
                using (new DepthWrapper(fg))
                {
                    fg.AppendLine($"root: root,");
                    fg.AppendLine($"item: this,");
                    fg.AppendLine($"doMasks: false,");
                    fg.AppendLine($"mask: out {obj.GetErrorMaskItemString()} errorMask,");
                    fg.AppendLine($"cmds: cmds);");
                }
            }
            fg.AppendLine();

            fg.AppendLine($"public virtual void CopyInFromXML(XElement root, out {obj.GetErrorMaskItemString()} errorMask, NotifyingFireParameters? cmds = null)");
            using (new BraceWrapper(fg))
            {
                fg.AppendLine($"NoggXmlTranslation<{obj.Name}, {obj.GetErrorMaskItemString()}>.Instance.CopyIn(");
                using (new DepthWrapper(fg))
                {
                    fg.AppendLine($"root: root,");
                    fg.AppendLine($"item: this,");
                    fg.AppendLine($"doMasks: true,");
                    fg.AppendLine($"mask: out errorMask,");
                    fg.AppendLine($"cmds: cmds);");
                }
            }
            fg.AppendLine();

            foreach (var baseClass in obj.BaseClassTrail())
            {
                fg.AppendLine("public override void CopyInFromXML(XElement root, out " + baseClass.GetErrorMaskItemString() + " errorMask, NotifyingFireParameters? cmds = null)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine($"var ret = new {obj.GetErrorMaskItemString()}();");
                    fg.AppendLine("errorMask = ret;");
                    fg.AppendLine("CopyInFromXML_Internal(root, ret, cmds: cmds);");
                }
                fg.AppendLine();
            }
        }
Esempio n. 10
0
 public override void GenerateForClass(FileGeneration fg)
 {
     if (this.Notifying)
     {
         if (AllowNull)
         {
             fg.AppendLine($"private readonly INotifyingItem<{TypeName}> {this.ProtectedProperty} = new NotifyingItem<{TypeName}>();");
         }
         else if (SingletonMember)
         { // Singleton
             fg.AppendLine($"private readonly INotifyingItem<{TypeName}> {this.ProtectedProperty} = new NotifyingItemNoggSingleton<{TypeName}, {this.RefGen.InterfaceStr}, {this.Getter}>(new {this.RefGen.ObjectName}());");
         }
         else
         {
             fg.AppendLine("private readonly INotifyingItem<" + TypeName + "> " + this.ProtectedProperty + " = new NotifyingItem<" + TypeName + ">(");
             using (new DepthWrapper(fg))
             {
                 fg.AppendLine("defaultVal: new " + TypeName + "(),");
                 fg.AppendLine("incomingConverter: (oldV, i) =>");
                 using (new BraceWrapper(fg))
                 {
                     fg.AppendLine("if (i == null)");
                     using (new BraceWrapper(fg))
                     {
                         fg.AppendLine("i = new " + TypeName + "();");
                     }
                     fg.AppendLine("return new Tuple<" + TypeName + ", bool>(i, true);");
                 }
             }
             fg.AppendLine(");");
         }
         fg.AppendLine($"public INotifyingItem{(Protected ? "Getter" : string.Empty)}<{TypeName}> {this.Property} {{ get {{ return _{this.Name}; }} }}");
         fg.AppendLine($"{this.Getter} {this.ObjectGen.Getter_InterfaceStr}.{this.Name}");
         using (new BraceWrapper(fg))
         {
             fg.AppendLine("get { return " + this.Name + "; }");
         }
         fg.AppendLine("public " + TypeName + " " + this.Name + " { get { return _" + this.Name + ".Value; } " + (this.Protected ? string.Empty : "set { _" + this.Name + ".Value = value; } ") + "}");
         if (!this.ReadOnly)
         {
             fg.AppendLine($"INotifyingItem<{this.TypeName}> {this.ObjectGen.InterfaceStr}.{this.Property} {{ get {{ return this.{this.Property}; }} }}");
         }
         fg.AppendLine($"INotifyingItemGetter<{this.TypeName}> {this.ObjectGen.Getter_InterfaceStr}.{this.Property} {{ get {{ return this.{this.Property}; }} }}");
     }
     else
     {
         fg.AppendLine($"private {(this.ReadOnly ? "readonly" : string.Empty)} HasBeenSetItem<{this.TypeName}> {this.ProtectedProperty} = new HasBeenSetItem<{this.TypeName}>();");
         fg.AppendLine($"public {this.Getter} {this.Name} {{ get {{ return this.{this.ProtectedName}; }} {(Protected ? "protected " : string.Empty)}set {{ {this.ProtectedName} = value; }} }}");
         if (this.ReadOnly)
         {
             fg.AppendLine($"public IHasBeenSetGetter {this.Property} {{ get {{ return this.{this.Property}; }} }}");
         }
         else
         {
             fg.AppendLine($"public IHasBeenSet<{this.TypeName}> {this.Property} {{ get {{ return {this.ProtectedProperty}; }} }}");
         }
         fg.AppendLine($"{this.Getter} {this.ObjectGen.Getter_InterfaceStr}.{this.Name} {{ get {{ return this.{this.ProtectedName}; }} }}");
     }
 }
Esempio n. 11
0
 public override void GenerateForClass(FileGeneration fg)
 {
     if (this.Notifying)
     {
         this.GenerateNotifyingCtor(fg);
         fg.AppendLine($"public {(Protected ? "INotifyingItemGetter" : "INotifyingItem")}<{TypeName}> {this.Property} {{ get {{ return _{this.Name}; }} }}");
         fg.AppendLine($"public {TypeName} {this.Name} {{ get {{ return _{this.Name}.Value; }} {(Protected ? "protected " : string.Empty)}set {{ _{this.Name}.Value = value; }} }}");
         if (!this.ReadOnly)
         {
             fg.AppendLine($"INotifyingItem<{this.TypeName}> {this.ObjectGen.InterfaceStr}.{this.Property} {{ get {{ return this.{this.Property}; }} }}");
         }
         fg.AppendLine($"INotifyingItemGetter<{this.TypeName}> {this.ObjectGen.Getter_InterfaceStr}.{this.Property} {{ get {{ return this.{this.Property}; }} }}");
     }
     else
     {
         if (!this.TrueReadOnly)
         {
             fg.AppendLine($"private readonly HasBeenSetItem<{this.TypeName}> _{this.Name} = new HasBeenSetItem<{this.TypeName}>();");
             fg.AppendLine($"public IHasBeenSet<{this.TypeName}> {this.Property} {{ get {{ return _{this.Name}; }} }}");
             fg.AppendLine($"public {this.TypeName} {this.Name} {{ get {{ return this._{this.Name}.Item; }} {(Protected ? "protected " : string.Empty)}set {{ this._{this.Name}.Set(value); }} }}");
             fg.AppendLine($"{this.TypeName} {this.ObjectGen.Getter_InterfaceStr}.{this.Name} {{ get {{ return this.{this.Name}; }} }}");
             fg.AppendLine($"IHasBeenSetGetter {this.ObjectGen.Getter_InterfaceStr}.{this.Property} {{ get {{ return this.{this.Property}; }} }}");
         }
         else
         {
             fg.AppendLine($"public readonly {this.TypeName} {this.Name};");
             fg.AppendLine($"{this.TypeName} {this.ObjectGen.Getter_InterfaceStr}.{this.Name} {{ get {{ return this.{this.Name}; }} }}");
             fg.AppendLine($"IHasBeenSetGetter {this.ObjectGen.Getter_InterfaceStr}.{this.Property} {{ get {{ return HasBeenSetGetter.NotBeenSet_Instance; }} }}");
         }
     }
 }
Esempio n. 12
0
 public override void GenerateForCopy(FileGeneration fg, string accessorPrefix, string rhsAccessorPrefix, string defaultFallbackAccessor, string cmdAccessor)
 {
     fg.AppendLine($"if ({rhsAccessorPrefix}.{this.HasBeenSetAccessor})");
     using (new BraceWrapper(fg))
     {
         if (defaultFallbackAccessor == null || !this.isNoggSingle)
         {
             GenerateCopy(fg, accessorPrefix, rhsAccessorPrefix, cmdAccessor);
         }
         else
         {
             fg.AppendLine("int i = 0;");
             fg.AppendLine("List<" + this.ItemTypeName + "> defList = " + defaultFallbackAccessor + "?." + this.Name + ".ToList();");
             fg.AppendLine(accessorPrefix + "." + this.Name + ".SetTo(");
             using (new DepthWrapper(fg))
             {
                 fg.AppendLine(rhsAccessorPrefix + "." + this.Name + ".Select((s) =>");
                 using (new BraceWrapper(fg))
                 {
                     fg.AppendLine("return s.Copy(defList?[i++]);");
                 }
             }
             fg.AppendLine("), " + cmdAccessor + ");");
         }
     }
     fg.AppendLine("else");
     using (new BraceWrapper(fg))
     {
         fg.AppendLine("if (" + defaultFallbackAccessor + " == null)");
         using (new BraceWrapper(fg))
         {
             fg.AppendLine(accessorPrefix + "." + this.Name + ".Unset(" + cmdAccessor + ".ToUnsetParams());");
         }
         fg.AppendLine("else");
         using (new BraceWrapper(fg))
         {
             GenerateCopy(fg, accessorPrefix, defaultFallbackAccessor, cmdAccessor);
         }
     }
 }
Esempio n. 13
0
 public override void GenerateForGetterInterface(FileGeneration fg)
 {
     fg.AppendLine(GetterTypeName + " GetNth" + this.Name + "(int index);");
     fg.AppendLine("INotifyingListGetter<" + ItemTypeName + "> " + this.Name + " { get; }");
 }
Esempio n. 14
0
 public override void GenerateForClass(FileGeneration fg)
 {
     fg.AppendLine("private readonly INotifyingList<" + ItemTypeName + "> _" + this.Name + " = new NotifyingList<" + ItemTypeName + ">();");
     fg.AppendLine($"public INotifyingList{(this.Protected ? "Getter" : string.Empty)}<{ItemTypeName}> {this.Name} {{ get {{ return _{this.Name}; }} }}");
     GenerateInterfaceMembers(fg, "_" + this.Name);
 }
Esempio n. 15
0
 private void GenerateCopy(FileGeneration fg, string accessorPrefix, string rhsAccessorPrefix, string cmdAccessor)
 {
     fg.AppendLine(accessorPrefix + "." + this.Name + ".SetTo(" + rhsAccessorPrefix + "." + this.Name + (this.isNoggSingle ? ".Select((s) => s.Copy())" : string.Empty) + ", " + cmdAccessor + ");");
 }
 public override void GenerateForCopy(FileGeneration fg, string accessorPrefix, string rhsAccessorPrefix, string defaultFallbackAccessor, string cmdsAccessor)
 {
     fg.AppendLine($"if ({rhsAccessorPrefix}.{this.HasBeenSetAccessor})");
     using (new BraceWrapper(fg))
     {
         if (defaultFallbackAccessor == null || (!this.KeyIsNogg && !this.ValueIsNogg))
         {
             GenerateCopy(fg, accessorPrefix, rhsAccessorPrefix, cmdsAccessor);
         }
         else
         {
             fg.AppendLine("int i = 0;");
             fg.AppendLine($"List<{this.TypeTuple}> defList = {defaultFallbackAccessor}?.{this.Name}.ToList();");
             fg.AppendLine(accessorPrefix + "." + this.Name + ".SetTo(");
             using (new DepthWrapper(fg))
             {
                 fg.AppendLine(rhsAccessorPrefix + "." + this.Name + ".Select((s) =>");
                 using (new BraceWrapper(fg))
                 {
                     fg.AppendLine("var ret = new " + this.TypeName + "();");
                     fg.AppendLine("if (defList != null && defList.InRange(i))");
                     using (new BraceWrapper(fg))
                     {
                         fg.AppendLine("ret.CopyFieldsFrom(s, defList[i++]);");
                     }
                     fg.AppendLine("else");
                     using (new BraceWrapper(fg))
                     {
                         fg.AppendLine("ret.CopyFieldsFrom(s);");
                     }
                     fg.AppendLine("return ret;");
                 }
             }
             fg.AppendLine("), " + cmdsAccessor + ");");
         }
     }
     fg.AppendLine("else");
     using (new BraceWrapper(fg))
     {
         fg.AppendLine("if (" + defaultFallbackAccessor + " == null)");
         using (new BraceWrapper(fg))
         {
             fg.AppendLine(accessorPrefix + "." + this.Name + ".Unset(" + cmdsAccessor + ".ToUnsetParams());");
         }
         fg.AppendLine("else");
         using (new BraceWrapper(fg))
         {
             GenerateCopy(fg, accessorPrefix, defaultFallbackAccessor, cmdsAccessor);
         }
     }
 }
 public override void GenerateSetException(FileGeneration fg, TypeGeneration field)
 {
     fg.AppendLine($"this.{field.Name} = ex;");
 }
 public override void GenerateSetMask(FileGeneration fg, TypeGeneration field)
 {
     fg.AppendLine($"this.{field.Name} = (Exception)obj;");
 }
        private void GenerateWrite(ObjectGeneration obj, FileGeneration fg)
        {
            if (obj.IsTopClass)
            {
                fg.AppendLine("public void WriteXMLToStream(Stream stream)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine("using (var writer = new XmlTextWriter(stream, Encoding.ASCII))");
                    using (new BraceWrapper(fg))
                    {
                        fg.AppendLine("writer.Formatting = Formatting.Indented;");
                        fg.AppendLine("writer.Indentation = 3;");
                        fg.AppendLine("WriteXML(writer);");
                    }
                }
                fg.AppendLine();
            }

            if (obj.Abstract)
            {
                if (!obj.BaseClass?.Abstract ?? true)
                {
                    fg.AppendLine("public abstract void WriteXML(XmlWriter writer, string name = null);");
                    fg.AppendLine();
                }
            }
            else if (obj.IsTopClass ||
                     (!obj.Abstract && (obj.BaseClass?.Abstract ?? true)))
            {
                fg.AppendLine($"public void WriteXML(XmlWriter writer, out {obj.GetErrorMaskItemString()} errorMask, string name = null)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine($"NoggXmlTranslation<{obj.Name}, {obj.GetErrorMaskItemString()}>.Instance.Write(");
                    using (new DepthWrapper(fg))
                    {
                        fg.AppendLine($"writer: writer,");
                        fg.AppendLine($"name: name,");
                        fg.AppendLine($"item: this,");
                        fg.AppendLine($"doMasks: true,");
                        fg.AppendLine($"mask: out errorMask);");
                    }
                }
                fg.AppendLine();

                fg.AppendLine($"public{obj.FunctionOverride}void WriteXML(XmlWriter writer, string name)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine($"NoggXmlTranslation<{obj.Name}, {obj.GetErrorMaskItemString()}>.Instance.Write(");
                    using (new DepthWrapper(fg))
                    {
                        fg.AppendLine($"writer: writer,");
                        fg.AppendLine($"name: name,");
                        fg.AppendLine($"item: this,");
                        fg.AppendLine($"doMasks: false,");
                        fg.AppendLine($"mask: out {obj.GetErrorMaskItemString()} errorMask);");
                    }
                }
                fg.AppendLine();

                fg.AppendLine($"public{obj.FunctionOverride}void WriteXML(XmlWriter writer)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine($"NoggXmlTranslation<{obj.Name}, {obj.GetErrorMaskItemString()}>.Instance.Write(");
                    using (new DepthWrapper(fg))
                    {
                        fg.AppendLine($"writer: writer,");
                        fg.AppendLine($"name: null,");
                        fg.AppendLine($"item: this,");
                        fg.AppendLine($"doMasks: false,");
                        fg.AppendLine($"mask: out {obj.GetErrorMaskItemString()} errorMask);");
                    }
                }
                fg.AppendLine();
            }
        }
 public override void GenerateForField(FileGeneration fg, TypeGeneration field, string typeStr)
 {
     fg.AppendLine($"public {typeStr} {field.Name};");
 }
Esempio n. 21
0
        public override void Generate(ObjectGeneration obj, FileGeneration fg)
        {
            fg.AppendLine($"public class {obj.Name}_Mask<T> {(obj.HasBaseObject ? " : " + obj.BaseClass.GetMaskString("T") : string.Empty)}");
            using (new BraceWrapper(fg))
            {
                foreach (var field in obj.Fields)
                {
                    if (!FieldMapping.TryGetValue(field.GetType(), out MaskModuleField fieldGen))
                    {
                        fieldGen = TypicalField;
                    }
                    fieldGen.GenerateForField(fg, field, "T");
                }
            }
            fg.AppendLine();

            fg.AppendLine($"public class {obj.Name}_ErrorMask : {(obj.HasBaseObject ? $"{obj.BaseClass.Name}_ErrorMask" : "IErrorMask")}");
            using (new BraceWrapper(fg))
            {
                fg.AppendLine("public Exception Overall { get; set; }");
                fg.AppendLine("private List<string> _warnings;");
                fg.AppendLine("public List<string> Warnings");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine("get");
                    using (new BraceWrapper(fg))
                    {
                        fg.AppendLine("if (_warnings == null)");
                        using (new BraceWrapper(fg))
                        {
                            fg.AppendLine("_warnings = new List<string>();");
                        }
                        fg.AppendLine("return _warnings;");
                    }
                }
                foreach (var field in obj.Fields)
                {
                    if (!FieldMapping.TryGetValue(field.GetType(), out MaskModuleField fieldGen))
                    {
                        fieldGen = TypicalField;
                    }
                    fieldGen.GenerateForErrorMask(fg, field);
                }
                fg.AppendLine();

                fg.AppendLine("public void SetNthException(ushort index, Exception ex)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine("switch (index)");
                    using (new BraceWrapper(fg))
                    {
                        foreach (var item in obj.IterateFields())
                        {
                            fg.AppendLine($"case {item.Index}:");
                            using (new DepthWrapper(fg))
                            {
                                if (!FieldMapping.TryGetValue(item.Field.GetType(), out MaskModuleField fieldGen))
                                {
                                    fieldGen = TypicalField;
                                }
                                fieldGen.GenerateSetException(fg, item.Field);
                                fg.AppendLine("break;");
                            }
                        }

                        obj.GenerateStandardIndexDefault(fg, "SetNthException", "index", false);
                    }
                }
                fg.AppendLine();

                fg.AppendLine("public void SetNthMask(ushort index, object obj)");
                using (new BraceWrapper(fg))
                {
                    fg.AppendLine("switch (index)");
                    using (new BraceWrapper(fg))
                    {
                        foreach (var item in obj.IterateFields())
                        {
                            fg.AppendLine($"case {item.Index}:");
                            using (new DepthWrapper(fg))
                            {
                                if (!FieldMapping.TryGetValue(item.Field.GetType(), out MaskModuleField fieldGen))
                                {
                                    fieldGen = TypicalField;
                                }
                                fieldGen.GenerateSetMask(fg, item.Field);
                                fg.AppendLine("break;");
                            }
                        }

                        obj.GenerateStandardIndexDefault(fg, "SetNthMask", "index", false);
                    }
                }
            }
        }
 protected override void GenerateEqualsCode(FileGeneration fg)
 {
     fg.AppendLine(this.ObjectName + " rhs = obj as " + this.ObjectName + ";");
     fg.AppendLine("if (rhs == null) return false;");
     fg.AppendLine("return Equals(obj);");
 }
Esempio n. 23
0
 public RegionWrapper(FileGeneration fg, string str)
 {
     this.fg = fg;
     fg.AppendLine("#region " + str);
 }
Esempio n. 24
0
        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"));
        }
 public override void GenerateSetNthHasBeenSet(FileGeneration fg, string identifier, string onIdentifier, bool internalUse)
 {
     fg.AppendLine(identifier + "." + this.GetPropertyString(internalUse) + ".Unset();");
 }
Esempio n. 26
0
        public override void GenerateForErrorMask(FileGeneration fg, TypeGeneration field)
        {
            NoggType nogg = field as NoggType;

            fg.AppendLine($"public MaskItem<Exception, {nogg.GenerateErrorMaskItemString()}> {field.Name};");
        }
 public override void GenerateForGetterInterface(FileGeneration fg)
 {
     fg.AppendLine($"INotifyingKeyedCollectionGetter<{this.TypeTuple}> {this.Name} {{ get; }}");
 }
Esempio n. 28
0
        public override void GenerateForField(FileGeneration fg, TypeGeneration field, string typeStr)
        {
            NoggType nogg = field as NoggType;

            fg.AppendLine($"public MaskItem<{typeStr}, {nogg.GenerateMaskString(typeStr)}> {field.Name} {{ get; set; }}");
        }
 public override void GenerateClear(FileGeneration fg, string accessorPrefix, string cmdAccessor)
 {
     fg.AppendLine(accessorPrefix + "." + this.Name + ".Unset(" + cmdAccessor + ".ToUnsetParams());");
 }
Esempio n. 30
0
 public override void GenerateForInterface(FileGeneration fg)
 {
     fg.AppendLine("new INotifyingContainer2D" + (this.Protected ? "Getter" : string.Empty) + "<" + ItemTypeName + "> " + this.GetPropertyString(false) + " { get; }");
 }