public override void Load(XElement node, bool requireName = true) { base.Load(node, requireName); if (!node.Elements().Any()) { throw new ArgumentException("List had no elements."); } if (node.Elements().Any() && ObjectGen.LoadField( node.Elements().First(), false, out SingleTypeGen)) { singleType = true; isNoggSingle = SingleTypeGen as NoggType != null; } else { throw new NotImplementedException(); } if (this.Derivative) { throw new NotImplementedException(); } }
public override async Task Load(XElement node, bool requireName = true) { await base.Load(node, requireName); var keyNode = node.Element(XName.Get("Key", LoquiGenerator.Namespace)); if (keyNode == null) { throw new ArgumentException("Dict had no key element."); } var keyTypeGen = await ObjectGen.LoadField( keyNode.Elements().FirstOrDefault(), requireName : false, setDefaults : false); if (keyTypeGen.Succeeded) { KeyTypeGen = keyTypeGen.Value; KeyIsLoqui = keyTypeGen.Value as LoquiType != null; } else { throw new NotImplementedException(); } var valNode = node.Element(XName.Get("Value", LoquiGenerator.Namespace)); if (valNode == null) { throw new ArgumentException("Dict had no value element."); } var valueTypeGen = await ObjectGen.LoadField( valNode.Elements().FirstOrDefault(), requireName : false, setDefaults : false); if (valueTypeGen.Succeeded) { ValueTypeGen = valueTypeGen.Value; ValueIsLoqui = valueTypeGen.Value is LoquiType; } else { throw new NotImplementedException(); } if (keyTypeGen.Value is ContainerType || keyTypeGen.Value is DictType) { throw new NotImplementedException(); } if (valueTypeGen.Value is ContainerType || valueTypeGen.Value is DictType) { throw new NotImplementedException(); } }
public override async Task Load(XElement node, bool requireName = true) { var fieldsNode = node.Element(XName.Get(Constants.FIELDS, LoquiGenerator.Namespace)); if (fieldsNode != null) { foreach (var fieldNode in fieldsNode.Elements()) { var typeGen = await ObjectGen.LoadField(fieldNode, requireName : true); if (typeGen.Succeeded) { SubFields.Add(typeGen.Value); } } } }
public override void Load(XElement node, bool requireName = true) { base.Load(node, requireName); var keyNode = node.Element(XName.Get("Key", NoggolloquyGenerator.Namespace)); if (keyNode == null) { throw new ArgumentException("Dict had no key element."); } if (ObjectGen.LoadField( keyNode.Elements().FirstOrDefault(), false, out KeyTypeGen)) { KeyIsNogg = KeyTypeGen as NoggType != null; } else { throw new NotImplementedException(); } var valNode = node.Element(XName.Get("Value", NoggolloquyGenerator.Namespace)); if (valNode == null) { throw new ArgumentException("Dict had no value element."); } if (ObjectGen.LoadField( valNode.Elements().FirstOrDefault(), false, out ValueTypeGen)) { ValueIsNogg = ValueTypeGen as NoggType != null; } else { throw new NotImplementedException(); } }
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}"); } }
public override async Task Resolve() { await base.Resolve(); var protoID = ProtocolID ?? ObjectGen.ProtoGen.Protocol.Namespace; if (!ObjectGen.ProtoGen.Gen.TryGetProtocol(new ProtocolKey(protoID), out var protoGen)) { throw new ArgumentException($"Protocol did not exist {protoID}."); } if (!protoGen.FieldBatchesByName.TryGetValue(BatchName, out var batch)) { throw new ArgumentException($"Field batch did not exist {BatchName} in protocol {protoGen.Protocol.Namespace}"); } var index = ObjectGen.IterateFields().ToList().IndexOf(this); if (index == -1) { throw new ArgumentException("Could not find self in object's field list."); } foreach (var generic in batch.Generics) { ObjectGen.Generics[generic.Key] = generic.Value; } foreach (var field in batch.Fields) { var typeGen = await ObjectGen.LoadField(field.Node, requireName : true); if (typeGen.Succeeded) { ObjectGen.Fields.Insert(index++, typeGen.Value); await typeGen.Value.Resolve(); } } if (!ObjectGen.Fields.Remove(this)) { throw new ArgumentException("Could not remove self from object's field list."); } }
public override async Task Load(XElement node, bool requireName = true) { await base.Load(node, requireName); var fieldsNode = node.Elements().FirstOrDefault(f => f.Name.LocalName.Equals("Fields")); if (fieldsNode != null) { node = fieldsNode; } if (!node.Elements().Any()) { throw new ArgumentException("Wrapper had no elements."); } if (node.Elements().Any()) { var typeGen = await ObjectGen.LoadField( node.Elements().First(), requireName : false, setDefaults : false); if (typeGen.Succeeded) { SubTypeGeneration = typeGen.Value; isLoquiSingle = SubTypeGeneration as LoquiType != null; } else { throw new NotImplementedException(); } SubTypeGeneration.Parent = this; } else { throw new NotImplementedException(); } }
public override async Task Load(XElement node, bool requireName = true) { await base.Load(node, requireName); var keyedValNode = node.Element(XName.Get(Constants.KEYED_VALUE, LoquiGenerator.Namespace)); if (keyedValNode == null) { throw new ArgumentException("Dict had no keyed value element."); } var valType = await ObjectGen.LoadField( keyedValNode.Elements().FirstOrDefault(), requireName : false, setDefaults : false); if (valType.Succeeded && valType.Value is LoquiType) { ValueTypeGen = valType.Value as LoquiType; } else { throw new NotImplementedException(); } var keyAccessorAttr = keyedValNode.Attribute(XName.Get(Constants.KEY_ACCESSOR)); if (keyAccessorAttr == null) { throw new ArgumentException("Dict had no key accessor attribute."); } KeyAccessorString = keyAccessorAttr.Value; if (ValueTypeGen.GenericDef == null) { await ValueTypeGen.TargetObjectGeneration.LoadingCompleteTask.Task; KeyTypeGen = ValueTypeGen.TargetObjectGeneration.IterateFields(includeBaseClass: true).FirstOrDefault((f) => f.Name.Equals(keyAccessorAttr.Value)); if (KeyTypeGen == null) { throw new ArgumentException($"Dict had a key accessor attribute that didn't correspond to a field: {keyAccessorAttr.Value}"); } } else { if (!keyedValNode.TryGetAttribute <string>(Constants.KEY_TYPE, out var keyTypeName)) { throw new ArgumentException("Cannot have a generic keyed reference without manually specifying keyType"); } if (!ObjectGen.ProtoGen.Gen.TryGetTypeGeneration(keyTypeName, out var keyTypeGen)) { throw new ArgumentException($"Generic keyed type specification did not link to a known field type: {keyTypeName}"); } KeyTypeGen = keyTypeGen; } await base.Resolve(); if (KeyTypeGen is ContainerType || KeyTypeGen is DictType) { throw new NotImplementedException(); } }