/// <summary>
        /// Creates and returns the metadata provider for the specified DataController Type.
        /// </summary>
        /// <param name="dataControllerType">The DataController Type.</param>
        /// <returns>The metadata provider.</returns>
        internal static MetadataProvider CreateMetadataProvider(Type dataControllerType)
        {
            // construct a list of all types in the inheritance hierarchy for the controller
            List <Type> baseTypes = new List <Type>();
            Type        currType  = dataControllerType;

            while (currType != typeof(DataController))
            {
                baseTypes.Add(currType);
                currType = currType.BaseType;
            }

            // create our base reflection provider
            List <MetadataProvider>    providerList       = new List <MetadataProvider>();
            ReflectionMetadataProvider reflectionProvider = new ReflectionMetadataProvider();

            // Set the IsEntity function which consults the chain of providers.
            Func <Type, bool> isEntityTypeFunc = (t) => providerList.Any(p => p.LookUpIsEntityType(t));

            reflectionProvider.SetIsEntityTypeFunc(isEntityTypeFunc);

            // Now from most derived to base, create any declared metadata providers,
            // chaining the instances as we progress. Note that ordering from derived to
            // base is important - we want to ensure that any providers the user has placed on
            // their DataController directly come before any DAL providers.
            MetadataProvider currProvider = reflectionProvider;

            providerList.Add(currProvider);
            for (int i = 0; i < baseTypes.Count; i++)
            {
                currType = baseTypes[i];

                // Reflection rather than TD is used here so we only get explicit
                // Type attributes. TD inherits attributes by default, even if the
                // attributes aren't inheritable.
                foreach (MetadataProviderAttribute providerAttribute in
                         currType.GetCustomAttributes(typeof(MetadataProviderAttribute), false))
                {
                    currProvider = providerAttribute.CreateProvider(dataControllerType, currProvider);
                    currProvider.SetIsEntityTypeFunc(isEntityTypeFunc);
                    providerList.Add(currProvider);
                }
            }

            return(currProvider);
        }
        /// <summary>
        /// Creates and returns the metadata provider for the specified DataController Type.
        /// </summary>
        /// <param name="dataControllerType">The DataController Type.</param>
        /// <returns>The metadata provider.</returns>
        internal static MetadataProvider CreateMetadataProvider(Type dataControllerType)
        {
            // construct a list of all types in the inheritance hierarchy for the controller
            List<Type> baseTypes = new List<Type>();
            Type currType = dataControllerType;
            while (currType != typeof(DataController))
            {
                baseTypes.Add(currType);
                currType = currType.BaseType;
            }

            // create our base reflection provider
            List<MetadataProvider> providerList = new List<MetadataProvider>();
            ReflectionMetadataProvider reflectionProvider = new ReflectionMetadataProvider();

            // Set the IsEntity function which consults the chain of providers.
            Func<Type, bool> isEntityTypeFunc = (t) => providerList.Any(p => p.LookUpIsEntityType(t));
            reflectionProvider.SetIsEntityTypeFunc(isEntityTypeFunc);

            // Now from most derived to base, create any declared metadata providers,
            // chaining the instances as we progress. Note that ordering from derived to
            // base is important - we want to ensure that any providers the user has placed on
            // their DataController directly come before any DAL providers.
            MetadataProvider currProvider = reflectionProvider;
            providerList.Add(currProvider);
            for (int i = 0; i < baseTypes.Count; i++)
            {
                currType = baseTypes[i];

                // Reflection rather than TD is used here so we only get explicit
                // Type attributes. TD inherits attributes by default, even if the
                // attributes aren't inheritable.
                foreach (MetadataProviderAttribute providerAttribute in
                    currType.GetCustomAttributes(typeof(MetadataProviderAttribute), false))
                {
                    currProvider = providerAttribute.CreateProvider(dataControllerType, currProvider);
                    currProvider.SetIsEntityTypeFunc(isEntityTypeFunc);
                    providerList.Add(currProvider);
                }
            }

            return currProvider;
        }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 public StandardMetadataProvider()
 {
     this.reflectionProvider = new ReflectionMetadataProvider();
     this.dynamicProvider    = new DynamicMetadataProvider(this.reflectionProvider);
 }
예제 #4
0
 public void TestInitialize()
 {
     this.metadataProvider = new ReflectionMetadataProvider();
 }