Exemple #1
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private static void Initialize()
        {
            var configuration = (DataProviderConfiguration)ConfigurationManager.GetSection("DataProvider");

            if (configuration == null || configuration.DefaultProvider == null || configuration.Providers == null || configuration.Providers.Count < 1)
            {
                throw new ProviderException("You must specify a valid default data provider.");
            }

            Providers = new DataProviderCollection();
            ProvidersHelper.InstantiateProviders(configuration.Providers, Providers, typeof(DataProvider));
            Providers.SetReadOnly();
            Provider = Providers[configuration.DefaultProvider];

            if (Provider == null)
            {
                var propertyInformation = configuration.ElementInformation.Properties["defaultProvider"];

                if (propertyInformation != null)
                {
                    throw new ConfigurationErrorsException(
                              "You must specify a default provider for the feature.",
                              propertyInformation.Source,
                              propertyInformation.LineNumber);
                }
            }
        }
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private static void Initialize()
        {
            var configuration = (DataProviderConfiguration)ConfigurationManager.GetSection("DataProvider");

            if (configuration == null || configuration.DefaultProvider == null || configuration.Providers == null || configuration.Providers.Count < 1)
                throw new ProviderException("You must specify a valid default data provider.");

            Providers = new DataProviderCollection();
            ProvidersHelper.InstantiateProviders(configuration.Providers, Providers, typeof(DataProvider));
            Providers.SetReadOnly();
            Provider = Providers[configuration.DefaultProvider];

            if (Provider == null)
            {
                var propertyInformation = configuration.ElementInformation.Properties["defaultProvider"];

                if (propertyInformation != null)
                    throw new ConfigurationErrorsException(
                        "You must specify a default provider for the feature.",
                        propertyInformation.Source,
                        propertyInformation.LineNumber);
            }
        }