示例#1
0
        private static void InitializeDefault()
        {
            // Use the default provider. WARNING: Don't forget to initialize it too!
            var tmpProvider = new DefaultAssetProvider();

            tmpProvider.Initialize(null, null);

            var tmpProviders = new AssetProviderCollection();

            tmpProviders.Add(tmpProvider);
            tmpProviders.SetReadOnly();

            s_Providers = tmpProviders;
            s_Provider  = tmpProvider;
        }
示例#2
0
        // Internal-only method for testing.
        // We use temporary objects to achieve exception-neutral code.
        internal static void InitializeCore(AssetSection section)
        {
            Debug.Assert(section != null);

            // Initialize the provider collection.
            var tmpProviders = new AssetProviderCollection();

            if (section.Providers != null)
            {
                ProvidersHelper.InstantiateProviders(section.Providers, tmpProviders, typeof(AssetProvider));
                tmpProviders.SetReadOnly();
            }

            s_Providers = tmpProviders;

            // Initialize the default provider.
            if (section.DefaultProvider == null)
            {
                throw new ProviderException(Strings.AssetManager_DefaultProviderNotConfigured);
            }

            var tmpProvider = s_Providers[section.DefaultProvider];

            if (tmpProvider == null)
            {
                // section.DefaultProvider is not null => propertyInfo != null.
                var propertyInfo
                    = section.ElementInformation
                      .Properties[AssetSection.DefaultProviderPropertyName];

                throw new ConfigurationErrorsException(
                          Strings.AssetManager_DefaultProviderNotFound,
                          propertyInfo.Source,
                          propertyInfo.LineNumber);
            }

            s_Provider = tmpProvider;
        }