private static EnumType ConvertToEnumType( SchemaEnumType somEnumType, Dictionary <SchemaElement, GlobalItem> newGlobalItems) { ScalarType underlyingType = (ScalarType)somEnumType.UnderlyingType; EnumType enumType = new EnumType(somEnumType.Name, somEnumType.Namespace, underlyingType.Type, somEnumType.IsFlags, DataSpace.CSpace); Type clrEquivalentType = underlyingType.Type.ClrEquivalentType; foreach (SchemaEnumMember enumMember1 in somEnumType.EnumMembers) { EnumMember enumMember2 = new EnumMember(enumMember1.Name, Convert.ChangeType((object)enumMember1.Value, clrEquivalentType, (IFormatProvider)CultureInfo.InvariantCulture)); if (enumMember1.Documentation != null) { enumMember2.Documentation = Converter.ConvertToDocumentation(enumMember1.Documentation); } Converter.AddOtherContent((SchemaElement)enumMember1, (MetadataItem)enumMember2); enumType.AddMember(enumMember2); } if (somEnumType.Documentation != null) { enumType.Documentation = Converter.ConvertToDocumentation(somEnumType.Documentation); } Converter.AddOtherContent((SchemaElement)somEnumType, (MetadataItem)enumType); newGlobalItems.Add((SchemaElement)somEnumType, (GlobalItem)enumType); return(enumType); }
private static EdmProperty ConvertToProperty( StructuredProperty somProperty, DbProviderManifest providerManifest, Converter.ConversionCache convertedItemCache, Dictionary <SchemaElement, GlobalItem> newGlobalItems) { ScalarType type = somProperty.Type as ScalarType; TypeUsage typeUsage; if (type != null && somProperty.Schema.DataModel != SchemaDataModelOption.EntityDataModel) { typeUsage = somProperty.TypeUsage; Converter.UpdateSentinelValuesInFacets(ref typeUsage); } else { EdmType edmType = type == null ? (EdmType)Converter.LoadSchemaElement(somProperty.Type, providerManifest, convertedItemCache, newGlobalItems) : (EdmType)convertedItemCache.ItemCollection.GetItem <PrimitiveType>(somProperty.TypeUsage.EdmType.FullName); if (somProperty.CollectionKind != CollectionKind.None) { typeUsage = TypeUsage.Create((EdmType) new CollectionType(edmType)); } else { SchemaEnumType schemaEnumType = type == null ? somProperty.Type as SchemaEnumType : (SchemaEnumType)null; typeUsage = TypeUsage.Create(edmType); if (schemaEnumType != null) { somProperty.EnsureEnumTypeFacets(convertedItemCache, newGlobalItems); } if (somProperty.TypeUsage != null) { Converter.ApplyTypePropertyFacets(somProperty.TypeUsage, ref typeUsage); } } } Converter.PopulateGeneralFacets(somProperty, ref typeUsage); EdmProperty edmProperty = new EdmProperty(somProperty.Name, typeUsage); if (somProperty.Documentation != null) { edmProperty.Documentation = Converter.ConvertToDocumentation(somProperty.Documentation); } Converter.AddOtherContent((SchemaElement)somProperty, (MetadataItem)edmProperty); return(edmProperty); }