private void DeserializeFrom(JNode jNode) { MetadataVersion = jNode.Get <String>("metadataVersion"); // may be more than just a name var ncNode = jNode.GetJNode("namingConvention"); var nc = FindOrCreateNamingConvention(ncNode); if (nc == null) { OnMetadataMismatch(null, null, MetadataMismatchType.MissingCLRNamingConvention, ncNode.ToString()); } else { NamingConvention = nc; } // localQueryComparisonOptions jNode.GetJNodeArray("dataServices").Select(jn => new DataService(jn)).ForEach(ds => { if (GetDataService(ds.ServiceName) == null) { AddDataService(ds); } }); jNode.GetJNodeArray("structuralTypes") .ForEach(UpdateStructuralTypeFromJNode); jNode.GetMap <String>("resourceEntityTypeMap").ForEach(kvp => { var et = GetEntityType(kvp.Value); SetResourceName(kvp.Key, et); }); }
internal void UpdateFromJNode(JNode jNode) { var shortName = jNode.Get <String>("shortName"); var ns = jNode.Get <String>("namespace"); var name = TypeNameInfo.QualifyTypeName(shortName, ns); var et = MetadataStore.Instance.GetEntityType(name); Check(et.BaseEntityTypeName, jNode.Get <String>("baseTypeName"), "BaseEntityType"); // For now this doesn't need to match et.IsAbstract = jNode.Get <bool>("isAbstract"); et.AutoGeneratedKeyType = jNode.GetEnum <AutoGeneratedKeyType>("autoGeneratedKeyType"); var drn = jNode.Get <String>("defaultResourceName"); if (drn != null) { MetadataStore.Instance.SetResourceName(drn, et, true); } jNode.GetJNodeArray("dataProperties").ForEach(jn => { var dpName = jn.Get <String>("name"); var dp = et.GetDataProperty(dpName); dp.UpdateFromJNode(jn); }); jNode.GetJNodeArray("navigationProperties").ForEach(jn => { var npName = jn.Get <String>("name"); var np = et.GetNavigationProperty(npName); np.UpdateFromJNode(jn); }); et._validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); // custom }
internal override void UpdateFromJNode(JNode jNode, bool isFromServer) { var name = this.MetadataStore.GetStructuralTypeNameFromJNode(jNode, isFromServer); var et = MetadataStore.GetEntityType(name); var baseTypeName = this.MetadataStore.GetStructuralTypeNameFromJNode(jNode, "baseTypeName", isFromServer); if (baseTypeName != null) { Check(et.BaseEntityTypeName, baseTypeName, "BaseEntityType"); } // For now this doesn't need to match et.IsAbstract = jNode.Get <bool>("isAbstract"); et.AutoGeneratedKeyType = jNode.GetEnum <AutoGeneratedKeyType>("autoGeneratedKeyType"); var drn = jNode.Get <String>("defaultResourceName"); if (drn != null) { MetadataStore.SetResourceName(drn, et, true); } jNode.GetJNodeArray("dataProperties").ForEach(jn => { var dpName = GetPropertyNameFromJNode(jn); var dp = et.GetDataProperty(dpName); if (dp == null) { MetadataStore.OnMetadataMismatch(name, dpName, MetadataMismatchTypes.MissingCLRDataProperty); return; } dp.UpdateFromJNode(jn, isFromServer); }); jNode.GetJNodeArray("navigationProperties").ForEach(jn => { var npName = GetPropertyNameFromJNode(jn); var np = et.GetNavigationProperty(npName); if (np == null) { MetadataStore.OnMetadataMismatch(name, npName, MetadataMismatchTypes.MissingCLRNavigationProperty); return; } np.UpdateFromJNode(jn, isFromServer); }); et._validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); // custom // next 2 lines are only needed if importing 'native' breeze metadata. if (et.KeyProperties.Count == 1 && et.AutoGeneratedKeyType != AutoGeneratedKeyType.None) { et.KeyProperties.First().IsAutoIncrementing = true; } }
internal void UpdateFromJNode(JNode jNode) { var complexTypeName = jNode.Get <String>("complexTypeName"); if (complexTypeName == null) { Check(DataType, DataType.FromName(jNode.Get <String>("dataType")), "DataType"); } else { Check(ComplexType.Name, complexTypeName, "ComplexTypeName"); } Check(this.IsScalar, jNode.Get <bool>("isScalar", true), "IsScalar"); 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"); _validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); }
internal void UpdateFromJNode(JNode jNode, bool isFromServer) { var complexTypeName = MetadataStore.GetStructuralTypeNameFromJNode(jNode, "complexTypeName", isFromServer); if (complexTypeName == null) { Check(DataType, DataType.FromName(jNode.Get <String>("dataType")), "DataType"); } else { Check(ComplexType.Name, complexTypeName, "ComplexTypeName"); } Check(this.IsScalar, jNode.Get <bool>("isScalar", true), "IsScalar"); IsNullable = jNode.Get <bool>("isNullable", true); if (DataType != null) { DefaultValue = jNode.Get("defaultValue", DataType.ClrType); if (DefaultValue == null && !IsNullable) { DefaultValue = DataType.DefaultValue; } } 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>("concurrencyMode", ConcurrencyMode.None.ToString())); MaxLength = jNode.Get <int?>("maxLength"); // EnumType is best determined on the client and not from the server // so for now just ignore the 'enumType' // var enumTypeName = jNode.Get<String>("enumType"); _validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); }
private void DeserializeFrom(JNode jNode, bool isFromServer) { MetadataVersion = jNode.Get <String>("metadataVersion"); // may be more than just a name var ncNode = jNode.GetJNode("namingConvention"); if (ncNode != null) { var nc = Configuration.Instance.FindOrCreateNamingConvention(ncNode); if (nc == null) { OnMetadataMismatch(null, null, MetadataMismatchTypes.MissingCLRNamingConvention, ncNode.ToString()); } else { // keep any preexisting ClientServerNamespaceMap info NamingConvention = nc.WithClientServerNamespaceMapping(this.NamingConvention.ClientServerNamespaceMap); } } // localQueryComparisonOptions jNode.GetJNodeArray("dataServices").Select(jn => new DataService(jn)).ForEach(ds => { if (GetDataService(ds.ServiceName) == null) { AddDataService(ds); } }); jNode.GetJNodeArray("structuralTypes") .ForEach(jn => UpdateStructuralTypeFromJNode(jn, isFromServer)); jNode.GetMap <String>("resourceEntityTypeMap").ForEach(kvp => { var stName = kvp.Value; if (isFromServer) { stName = TypeNameInfo.FromStructuralTypeName(stName).ToClient(this).StructuralTypeName; } // okIfNotFound because metadata may contain refs to types that were already excluded earlier in // UpdateStructuralTypeFromJNode var et = GetEntityType(stName, true); if (et != null) { SetResourceName(kvp.Key, et); } }); }
internal void UpdateFromJNode(JNode jNode) { Check(EntityType.Name, jNode.Get <String>("entityTypeName"), "EntityTypeName"); IsScalar = jNode.Get <bool>("isScalar", true); AssociationName = jNode.Get <String>("associationName"); _validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); SetFkNames(jNode.GetArray <String>("foreignKeyNames")); SetInvFkNames(jNode.GetArray <String>("invForeignKeyNames")); // custom }
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 (GetDataService(ds.ServiceName) == null) { AddDataService(ds); } }); jNode.GetJNodeArray("structuralTypes") .ForEach(UpdateStructuralTypeFromJNode); jNode.GetMap <String>("resourceEntityTypeMap").ForEach(kvp => { var et = GetEntityType(kvp.Value); SetResourceName(kvp.Key, et); }); }
internal void UpdateFromJNode(JNode jNode, bool isFromServer) { var etName = MetadataStore.GetStructuralTypeNameFromJNode(jNode, "entityTypeName", isFromServer); Check(EntityType.Name, etName, "EntityTypeName"); IsScalar = jNode.Get <bool>("isScalar", true); AssociationName = jNode.Get <String>("associationName"); _validators = new ValidatorCollection(jNode.GetJNodeArray("validators")); SetFkNames(jNode.GetArray <String>(isFromServer ? "foreignKeyNamesOnServer" : "foreignKeyNames")); SetInvFkNames(jNode.GetArray <String>(isFromServer ? "invForeignKeyNamesOnServer" : "invForeignKeyNames")); // custom }
internal override void UpdateFromJNode(JNode jNode, bool isFromServer) { Name = this.MetadataStore.GetStructuralTypeNameFromJNode(jNode, isFromServer); // BaseTypeName = jnode.Get<String>("baseTypeName"); // IsAbstract = jnode.Get<bool>("isAbstract"); jNode.GetJNodeArray("dataProperties").ForEach(jn => { var dpName = GetPropertyNameFromJNode(jn); var dp = this.GetDataProperty(dpName); dp.UpdateFromJNode(jn, isFromServer); }); // validators // custom }
public void UpdateFromJNode(JNode jNode) { var shortName = jNode.Get <String>("shortName"); var ns = jNode.Get <String>("namespace"); Name = TypeNameInfo.QualifyTypeName(shortName, ns); // BaseTypeName = jnode.Get<String>("baseTypeName"); // IsAbstract = jnode.Get<bool>("isAbstract"); jNode.GetJNodeArray("dataProperties").ForEach(jn => { var dpName = jn.Get <String>("name"); var dp = this.GetDataProperty(dpName); dp.UpdateFromJNode(jn); }); // validators // custom }