Example #1
0
        static bool EnsureProviderFactory()
        {
            if (resource_providers == null)
            {
                resource_providers = new Dictionary <string, IResourceProvider> ();
            }

            if (provider_factory != null)
            {
                return(true);
            }

            GlobalizationSection gs = WebConfigurationManager.GetSection("system.web/globalization") as GlobalizationSection;

            if (gs == null)
            {
                return(false);
            }

            String rsfTypeName  = gs.ResourceProviderFactoryType;
            bool   usingDefault = false;

            if (String.IsNullOrEmpty(rsfTypeName))
            {
                usingDefault = true;
                rsfTypeName  = typeof(DefaultResourceProviderFactory).AssemblyQualifiedName;
            }

            Type rsfType = HttpApplication.LoadType(rsfTypeName, true);
            ResourceProviderFactory rpf = Activator.CreateInstance(rsfType) as ResourceProviderFactory;

            if (rpf == null && usingDefault)
            {
                return(false);
            }

            provider_factory = rpf;
            if (usingDefault)
            {
                default_provider_factory = rpf as DefaultResourceProviderFactory;
            }

            return(true);
        }