public DataService(JNode jNode) { ServiceName = jNode.Get <String>("serviceName"); // Adapter = null; HasServerMetadata = jNode.Get <bool>("hasServerMetadata"); // JsonResultsAdapter UseJsonP = jNode.Get <bool>("useJsonp"); }
public DataService(JNode jNode) { ServiceName = jNode.Get <String>("serviceName"); HasServerMetadata = jNode.Get <bool>("hasServerMetadata"); UseJsonP = jNode.Get <bool>("useJsonp"); Adapter = GetAdapter(jNode.Get <String>("adapterName")); InitializeHttpClient(); }
public ComplexType(JNode jNode) { ShortName = jNode.Get <String>("shortName"); Namespace = jNode.Get <String>("namespace"); // BaseTypeName = jnode.Get<String>("baseTypeName"); // IsAbstract = jnode.Get<bool>("isAbstract"); jNode.GetJNodeArray("dataProperties").Select(jn => new DataProperty(jn)).ForEach(dp => AddDataProperty(dp)); // validators // custom }
public NavigationProperty(JNode jNode) { Name = jNode.Get <String>("name"); EntityTypeName = jNode.Get <String>("entityTypeName"); IsScalar = jNode.Get <bool>("isScalar", true); AssociationName = jNode.Get <String>("associationName"); // _validators.AddRange() _foreignKeyNames.AddRange(jNode.GetArray <String>("foreignKeyNames")); _invForeignKeyNames.AddRange(jNode.GetArray <String>("invForeignKeyNames")); // custom }
private void PopulateEntity(IEntity targetEntity, JNode jn) { var targetAspect = targetEntity.EntityAspect; var backingStore = targetAspect.BackingStore; var entityType = targetAspect.EntityType; entityType.DataProperties.ForEach(dp => { var propName = dp.Name; if (dp.IsComplexProperty) { var coNode = jn.GetJNode(propName); var newCo = (IComplexObject)coNode.ToObject(dp.ClrType); var targetCo = (IComplexObject)backingStore[propName]; var targetCoAspect = targetCo.ComplexAspect; var coBacking = targetCoAspect.BackingStore; newCo.ComplexAspect.BackingStore.ForEach(kvp2 => { coBacking[kvp2.Key] = kvp2.Value; }); UpdateOriginalValues(targetCoAspect, coNode); } else { var val = jn.Get(propName, dp.ClrType); backingStore[propName] = val; } }); UpdateOriginalValues(targetAspect, jn); }
internal EntityKey(JNode jn) { var etName = jn.Get <String>("entityType"); EntityType = MetadataStore.Instance.GetEntityType(etName); ClrType = EntityType.ClrType; // coerce the incoming data Values = jn.GetArray("values", EntityType.KeyProperties.Select(kp => kp.ClrType)).ToArray(); }
public EntityType(JNode jNode) { ShortName = jNode.Get <String>("shortName"); Namespace = jNode.Get <String>("namespace"); BaseTypeName = jNode.Get <String>("baseTypeName"); IsAbstract = jNode.Get <bool>("isAbstract"); AutoGeneratedKeyType = jNode.GetEnum <AutoGeneratedKeyType>("autoGeneratedKeyType"); var drn = jNode.Get <String>("defaultResourceName"); if (drn != null) { MetadataStore.Instance.AddResourceName(drn, this, true); } jNode.GetJNodeArray("dataProperties").Select(jn => new DataProperty(jn)).ForEach(dp => AddDataProperty(dp)); jNode.GetJNodeArray("navigationProperties").Select(jn => new NavigationProperty(jn)).ForEach(np => AddNavigationProperty(np)); // validators // custom }
private EntityKey ExtractEntityKey(EntityType entityType, JNode jn) { var keyValues = entityType.KeyProperties .Select(p => jn.Get(p.Name, p.ClrType)) .ToArray(); var entityKey = EntityKey.Create(entityType, keyValues); return(entityKey); }
private void DeserializeFrom(JNode jNode) { MetadataVersion = jNode.Get <String>("metadataVersion"); // Name NamingConvention = NamingConvention.FromName(jNode.Get <String>("namingConvention")); // localQueryComparisonOptions jNode.GetJNodeArray("dataServices").Select(jn => new DataService(jn)).ForEach(ds => { if (!_dataServiceMap.ContainsKey(ds.ServiceName)) { _dataServiceMap.Add(ds.ServiceName, ds); } }); var stypes = jNode.GetJNodeArray("structuralTypes") .Select(jn => jn.Get <bool>("isComplexType", false) ? (StructuralType) new ComplexType(jn) : (StructuralType) new EntityType(jn)); stypes.ForEach(st => this.AddStructuralType(st)); jNode.GetMap <String>("resourceEntityTypeMap").ForEach(kvp => { var et = GetEntityType(kvp.Value); AddResourceName(kvp.Key, et); }); }
private Validator ValidatorFromJNode(JNode jNode) { var vrName = jNode.Get <String>("name"); Type vrType; if (!_validatorMap.TryGetValue(vrName, out vrType)) { var e = new Exception("Unable to create a validator for " + vrName); _errors.Add(e); return(null); } // Deserialize the object var vr = (Validator)jNode.ToObject(vrType, true); return(vr); }
public DataProperty(JNode jNode) { Name = jNode.Get <String>("name"); ComplexTypeName = jNode.Get <String>("complexTypeName"); if (ComplexTypeName == null) { DataType = DataType.FromName(jNode.Get <String>("dataType")); } IsNullable = jNode.Get <bool>("isNullable", true); if (DataType != null) { DefaultValue = jNode.Get("defaultValue", DataType.ClrType); } IsPartOfKey = jNode.Get <bool>("isPartOfKey", false); IsUnmapped = jNode.Get <bool>("isUnmapped", false); IsAutoIncrementing = jNode.Get <bool>("isAutoIncrementing", false); ConcurrencyMode = (ConcurrencyMode)Enum.Parse(typeof(ConcurrencyMode), jNode.Get <String>("conncurrencyMode", ConcurrencyMode.None.ToString())); MaxLength = jNode.Get <int?>("maxLength"); EnumTypeName = jNode.Get <String>("enumType"); IsScalar = jNode.Get <bool>("isScalar", true); _validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); }