Exemplo n.º 1
0
        /// <summary>
        /// Builds <see cref="IEdmType"/> and <see cref="IEdmProperty"/>'s from <paramref name="configurations"/>
        /// </summary>
        /// <param name="configurations">A collection of <see cref="IEdmTypeConfiguration"/>'s</param>
        /// <returns>The built dictionary of <see cref="StructuralTypeConfiguration"/>'s indexed by their backing CLR type,
        /// and dictionary of <see cref="StructuralTypeConfiguration"/>'s indexed by their backing CLR property info</returns>
        public static EdmTypeMap GetTypesAndProperties(IEnumerable <IEdmTypeConfiguration> configurations)
        {
            if (configurations == null)
            {
                throw Error.ArgumentNull("configurations");
            }

            EdmTypeBuilder builder = new EdmTypeBuilder(configurations);

            return(new EdmTypeMap(builder.GetEdmTypes(),
                                  builder._properties,
                                  builder._propertiesRestrictions,
                                  builder._members,
                                  builder._openTypes));
        }
Exemplo n.º 2
0
        public static IEdmModel BuildEdmModel(ODataModelBuilder builder)
        {
            if (builder == null)
            {
                throw Error.ArgumentNull("builder");
            }

            EdmModel           model     = new EdmModel();
            EdmEntityContainer container = new EdmEntityContainer(builder.Namespace, builder.ContainerName);

            // add types and sets, building an index on the way.
            IEnumerable <IEdmTypeConfiguration> configTypes = builder.StructuralTypes.Concat <IEdmTypeConfiguration>(builder.EnumTypes);
            EdmTypeMap edmMap = EdmTypeBuilder.GetTypesAndProperties(configTypes);
            Dictionary <Type, IEdmType> edmTypeMap = model.AddTypes(edmMap);

            // Add EntitySets and build the mapping between the EdmEntitySet and the NavigationSourceConfiguration
            NavigationSourceAndAnnotations[] entitySets = container.AddEntitySetAndAnnotations(builder, edmTypeMap);

            // Add Singletons and build the mapping between the EdmSingleton and the NavigationSourceConfiguration
            NavigationSourceAndAnnotations[] singletons = container.AddSingletonAndAnnotations(builder, edmTypeMap);

            // Merge EntitySets and Singletons together
            IEnumerable <NavigationSourceAndAnnotations> navigationSources = entitySets.Concat(singletons);

            // Build the navigation source map
            IDictionary <string, EdmNavigationSource> navigationSourceMap = model.GetNavigationSourceMap(edmMap, navigationSources);

            // Add the core vocabulary annotations
            model.AddCoreVocabularyAnnotations(entitySets, edmMap);

            // Add the capabilities vocabulary annotations
            model.AddCapabilitiesVocabularyAnnotations(entitySets, edmMap);

            // add operations
            model.AddOperations(builder.Operations, container, edmTypeMap, navigationSourceMap);

            // finish up
            model.AddElement(container);

            // build the map from IEdmEntityType to IEdmFunctionImport
            model.SetAnnotationValue <BindableOperationFinder>(model, new BindableOperationFinder(model));

            return(model);
        }
Exemplo n.º 3
0
        private static Dictionary <Type, IEdmType> AddTypes(this EdmModel model, IEnumerable <StructuralTypeConfiguration> types,
                                                            IEnumerable <EnumTypeConfiguration> enumTypes
                                                            )
        {
            IEnumerable <IEdmTypeConfiguration> configTypes = types.Concat <IEdmTypeConfiguration>(enumTypes);
            // build types
            EdmTypeMap edmTypeMap = EdmTypeBuilder.GetTypesAndProperties(configTypes);
            Dictionary <Type, IEdmType> edmTypes = edmTypeMap.EdmTypes;

            // Add an annotate types
            model.AddTypes(edmTypes);
            model.AddClrTypeAnnotations(edmTypes);

            // add annotation for properties
            Dictionary <PropertyInfo, IEdmProperty> edmProperties = edmTypeMap.EdmProperties;

            model.AddClrPropertyInfoAnnotations(edmProperties);
            model.AddPropertyRestrictionsAnnotations(edmTypeMap.EdmPropertiesRestrictions);

            // add dynamic dictionary property annotation for open types
            model.AddDynamicPropertyDictionaryAnnotations(edmTypeMap.OpenTypes);

            return(edmTypes);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Builds <see cref="IEdmType"/> and <see cref="IEdmProperty"/>'s from <paramref name="configurations"/>
		/// </summary>
		/// <param name="configurations">A collection of <see cref="IEdmTypeConfiguration"/>'s</param>
		/// <returns>The built dictionary of <see cref="StructuralTypeConfiguration"/>'s indexed by their backing CLR type,
		/// and dictionary of <see cref="StructuralTypeConfiguration"/>'s indexed by their backing CLR property info</returns>
		public static EdmTypeMap GetTypesAndProperties(IEnumerable<IEdmTypeConfiguration> configurations)
		{
			if (configurations == null)
			{
				throw Error.ArgumentNull("configurations");
			}

			EdmTypeBuilder builder = new EdmTypeBuilder(configurations);
			return new EdmTypeMap(
				builder.GetEdmTypes(),
				builder._properties,
				builder._propertiesRestrictions,
				builder._members,
				builder._openTypes);
		}