public void AddMaskException(FileGeneration fg, string errorMaskAccessor, string exception, bool key)
        {
            NoggType valueNoggType = this.ValueTypeGen as NoggType;
            var      valStr        = valueNoggType == null ? "Exception" : $"Tuple<Exception, {valueNoggType.RefGen.Obj.GetMaskString("Exception")}>";

            fg.AppendLine($"{errorMaskAccessor}?.{this.Name}.Value.Add({(key ? "null" : exception)});");
        }
        public void AddMaskException(FileGeneration fg, string errorMaskMemberAccessor, string exception, bool key)
        {
            NoggType keyNoggType   = this.KeyTypeGen as NoggType;
            NoggType valueNoggType = this.ValueTypeGen as NoggType;
            var      item2         = $"KeyValuePair<{(keyNoggType == null ? "Exception" : keyNoggType.RefGen.Obj.GetMaskString("Exception"))}, {(valueNoggType == null ? "Exception" : valueNoggType.RefGen.Obj.GetMaskString("Exception"))}>";

            fg.AppendLine($"{errorMaskMemberAccessor}?.{this.Name}.Value.Add(new {item2}({(key ? exception : "null")}, {(key ? "null" : exception)}));");
        }
예제 #3
0
        public override void GenerateForField(FileGeneration fg, TypeGeneration field, string valueStr)
        {
            ContainerType listType = field as ContainerType;
            NoggType      noggType = listType.SubTypeGeneration as NoggType;
            string        listStr;

            if (noggType == null)
            {
                listStr = $"IEnumerable<{valueStr}>";
            }
            else
            {
                listStr = $"IEnumerable<{noggType.RefGen.Obj.GetErrorMaskItemString()}>";
            }
            fg.AppendLine($"public MaskItem<{valueStr}, {listStr}> {field.Name};");
        }
        public override void Load(XElement node, bool requireName = true)
        {
            base.Load(node, requireName);

            var keyedValNode = node.Element(XName.Get("KeyedValue", NoggolloquyGenerator.Namespace));

            if (keyedValNode == null)
            {
                throw new ArgumentException("Dict had no keyed value element.");
            }

            TypeGeneration valType;

            if (ObjectGen.LoadField(
                    keyedValNode.Elements().FirstOrDefault(),
                    false,
                    out valType) &&
                valType is NoggType)
            {
                this.ValueTypeGen = valType as NoggType;
            }
            else
            {
                throw new NotImplementedException();
            }

            var keyAccessorAttr = keyedValNode.Attribute(XName.Get("keyAccessor"));

            if (keyAccessorAttr == null)
            {
                throw new ArgumentException("Dict had no key accessor attribute.");
            }

            this.KeyAccessorString = keyAccessorAttr.Value;
            this.KeyTypeGen        = this.ValueTypeGen.RefGen.Obj.Fields.First((f) => f.Name.Equals(keyAccessorAttr.Value));
            if (this.KeyTypeGen == null)
            {
                throw new ArgumentException($"Dict had a key accessor attribute that didn't correspond to a field: {keyAccessorAttr.Value}");
            }
        }
예제 #5
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; }}");
        }
예제 #6
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 GenerateForField(FileGeneration fg, TypeGeneration field, string typeStr)
 {
     IDictType dictType      = field as IDictType;
     NoggType  keyNoggType   = dictType.KeyTypeGen as NoggType;
     NoggType  valueNoggType = dictType.ValueTypeGen as NoggType;
     string    valueStr      = $"{(valueNoggType == null ? typeStr : $"MaskItem<{typeStr}, {valueNoggType.RefGen.Obj.GetMaskString(typeStr)}>")}";