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}");
            }
        }
示例#2
0
        public override void Load(XElement node, bool requireName = true)
        {
            base.Load(node, requireName);

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

            if (keyedValueNode != null)
            {
                var dictType = new DictType_KeyedValue();
                dictType.ObjectGen = this.ObjectGen;
                subGenerator       = dictType;
                subGenerator.Load(node, requireName);
                subDictGenerator = dictType;
            }
            else
            {
                var dictType = new DictType_Typical();
                dictType.ObjectGen = this.ObjectGen;
                subGenerator       = dictType;
                subGenerator.Load(node, requireName);
                subDictGenerator = dictType;
            }
        }
示例#3
0
 public override void GenerateSetMask(FileGeneration fg, TypeGeneration field)
 {
     throw new NotImplementedException();
 }
示例#4
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 GenerateForField(FileGeneration fg, TypeGeneration field, string typeStr)
 {
     fg.AppendLine($"public {typeStr} {field.Name};");
 }
示例#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 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;");
 }
示例#9
0
 public virtual void GenerateForErrorMask(FileGeneration fg, TypeGeneration field)
 {
     GenerateForField(fg, field, "Exception");
 }
示例#10
0
 public abstract void GenerateForField(FileGeneration fg, TypeGeneration field, string valueStr);
示例#11
0
 public abstract void GenerateSetMask(FileGeneration fg, TypeGeneration field);
示例#12
0
 public abstract void GenerateSetException(FileGeneration fg, TypeGeneration field);
 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)}>")}";