private void AddSchema(CsdlSchema schema) { 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; } derivedTypes.Add(structuredType); } } } RegisterElement(type); } foreach (CsdlSemanticsAssociation association in schemaWrapper.Associations) { RegistrationHelper.AddElement(association, association.Namespace + "." + association.Name, this.associationDictionary, CreateAmbiguousAssociationBinding); } foreach (IEdmFunction function in schemaWrapper.Functions) { RegisterElement(function); } foreach (IEdmValueTerm valueTerm in schemaWrapper.ValueTerms) { RegisterElement(valueTerm); } foreach (IEdmEntityContainer container in schemaWrapper.EntityContainers) { RegisterElement(container); } foreach (CsdlAnnotations schemaOutOfLineAnnotations in schema.OutOfLineAnnotations) { string target = schemaOutOfLineAnnotations.Target; string replaced = schemaWrapper.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)); } foreach (CsdlUsing used in schema.Usings) { this.SetNamespaceAlias(used.Namespace, used.Alias); } var edmVersion = this.GetEdmVersion(); if (edmVersion == null || edmVersion < schema.Version) { this.SetEdmVersion(schema.Version); } }
private void AddSchema(CsdlSchema schema) { CsdlSemanticsSchema item = new CsdlSemanticsSchema(this, schema); this.schemata.Add(item); foreach (IEdmSchemaType type in item.Types) { CsdlSemanticsStructuredTypeDefinition definition = type as CsdlSemanticsStructuredTypeDefinition; if (definition != null) { string baseTypeName = ((CsdlNamedStructuredType)definition.Element).BaseTypeName; if (baseTypeName != null) { string str; string str2; EdmUtil.TryGetNamespaceNameFromQualifiedName(baseTypeName, out str, out str2); if (str2 != null) { List <IEdmStructuredType> list; if (!this.derivedTypeMappings.TryGetValue(str2, out list)) { list = new List <IEdmStructuredType>(); this.derivedTypeMappings[str2] = list; } list.Add(definition); } } } base.RegisterElement(type); } foreach (CsdlSemanticsAssociation association in item.Associations) { RegistrationHelper.AddElement <IEdmAssociation>(association, association.Namespace + "." + association.Name, this.associationDictionary, new Func <IEdmAssociation, IEdmAssociation, IEdmAssociation>(CsdlSemanticsModel.CreateAmbiguousAssociationBinding)); } foreach (IEdmFunction function in item.Functions) { base.RegisterElement(function); } foreach (IEdmValueTerm term in item.ValueTerms) { base.RegisterElement(term); } foreach (IEdmEntityContainer container in item.EntityContainers) { base.RegisterElement(container); } foreach (CsdlAnnotations annotations in schema.OutOfLineAnnotations) { List <CsdlSemanticsAnnotations> list2; string target = annotations.Target; string str5 = item.ReplaceAlias(target); if (str5 != null) { target = str5; } if (!this.outOfLineAnnotations.TryGetValue(target, out list2)) { list2 = new List <CsdlSemanticsAnnotations>(); this.outOfLineAnnotations[target] = list2; } list2.Add(new CsdlSemanticsAnnotations(item, annotations)); } foreach (CsdlUsing @using in schema.Usings) { this.SetNamespaceAlias(@using.Namespace, @using.Alias); } Version edmVersion = this.GetEdmVersion(); if ((edmVersion == null) || (edmVersion < schema.Version)) { this.SetEdmVersion(schema.Version); } }