/// <summary> /// Registers schema elements (entity types, operations, entity containers, etc.) from the /// specified schema into the model. /// </summary> /// <param name="schemaWrapper">The <see cref="CsdlSemanticsSchema"/> to add elements from</param> private void AddSchemaElements(CsdlSemanticsSchema schemaWrapper) { foreach (IEdmSchemaType type in schemaWrapper.Types) { CsdlSemanticsStructuredTypeDefinition structuredType = type as CsdlSemanticsStructuredTypeDefinition; if (structuredType != null) { string baseTypeName; string baseTypeFullName = ((CsdlNamedStructuredType)structuredType.Element).BaseTypeName; if (baseTypeFullName != null) { EdmUtil.TryGetNamespaceNameFromQualifiedName(baseTypeFullName, out _, out baseTypeName); if (baseTypeName != null) { List <IEdmStructuredType> derivedTypes; if (!this.derivedTypeMappings.TryGetValue(baseTypeName, out derivedTypes)) { derivedTypes = new List <IEdmStructuredType>(); this.derivedTypeMappings[baseTypeName] = derivedTypes; } // TODO: REF referenced derived types derivedTypes.Add(structuredType); } } } RegisterElement(type); } foreach (IEdmOperation function in schemaWrapper.Operations) { RegisterElement(function); } foreach (IEdmTerm valueTerm in schemaWrapper.Terms) { RegisterElement(valueTerm); } foreach (IEdmEntityContainer container in schemaWrapper.EntityContainers) { RegisterElement(container); } }
public CsdlSemanticsNavigationProperty(CsdlSemanticsStructuredTypeDefinition declaringType, CsdlNavigationProperty navigationProperty) : base(navigationProperty) { this.declaringType = declaringType; this.navigationProperty = navigationProperty; }
private void AddSchema(CsdlSchema schema, bool addAnnotations) { CsdlSemanticsSchema schemaWrapper = new CsdlSemanticsSchema(this, schema); this.schemata.Add(schemaWrapper); foreach (IEdmSchemaType type in schemaWrapper.Types) { CsdlSemanticsStructuredTypeDefinition structuredType = type as CsdlSemanticsStructuredTypeDefinition; if (structuredType != null) { string baseTypeNamespace; string baseTypeName; string baseTypeFullName = ((CsdlNamedStructuredType)structuredType.Element).BaseTypeName; if (baseTypeFullName != null) { EdmUtil.TryGetNamespaceNameFromQualifiedName(baseTypeFullName, out baseTypeNamespace, out baseTypeName); if (baseTypeName != null) { List <IEdmStructuredType> derivedTypes; if (!this.derivedTypeMappings.TryGetValue(baseTypeName, out derivedTypes)) { derivedTypes = new List <IEdmStructuredType>(); this.derivedTypeMappings[baseTypeName] = derivedTypes; } // TODO: REF referenced derived types derivedTypes.Add(structuredType); } } } RegisterElement(type); } foreach (IEdmOperation function in schemaWrapper.Operations) { RegisterElement(function); } foreach (IEdmTerm valueTerm in schemaWrapper.Terms) { RegisterElement(valueTerm); } foreach (IEdmEntityContainer container in schemaWrapper.EntityContainers) { RegisterElement(container); } if (!string.IsNullOrEmpty(schema.Alias)) { this.SetNamespaceAlias(schema.Namespace, schema.Alias); } if (addAnnotations) { foreach (CsdlAnnotations schemaOutOfLineAnnotations in schema.OutOfLineAnnotations) { string target = schemaOutOfLineAnnotations.Target; string replaced = this.ReplaceAlias(target); if (replaced != null) { target = replaced; } List <CsdlSemanticsAnnotations> annotations; if (!this.outOfLineAnnotations.TryGetValue(target, out annotations)) { annotations = new List <CsdlSemanticsAnnotations>(); this.outOfLineAnnotations[target] = annotations; } annotations.Add(new CsdlSemanticsAnnotations(schemaWrapper, schemaOutOfLineAnnotations)); } } var edmVersion = this.GetEdmVersion(); if (edmVersion == null || edmVersion < schema.Version) { this.SetEdmVersion(schema.Version); } }
public CsdlSemanticsProperty(CsdlSemanticsStructuredTypeDefinition declaringType, CsdlProperty property) : base(property) { this.property = property; this.declaringType = declaringType; }