private static void EnsureResourceProviderFactory() { if (s_resourceProviderFactory == null) { s_resourceProviderFactory = new ExternalResourceProviderFactory(); } }
private static void EnsureResourceProviderFactory() { if (DBResourceExpressionBuilder.s_resourceProviderFactory == null) { DBResourceExpressionBuilder.s_resourceProviderFactory = new DBResourceProviderFactory(); } }
private object GetObjectInternal(string resourceKey, string cultureName) { IDictionary resources = this.GetResourceCache(cultureName); object value = null; if (resources == null) { value = null; } else { value = resources[resourceKey]; } // If we're at a specific culture (en-US) and there's no value, then fall back // to the generic culture (en) if (value == null && cultureName.Length > 3) { // Try again with the 2 letter locale value = GetObjectInternal(resourceKey, cultureName.Substring(0, 2)); } // If the value is still null get the invariant value if (value == null && cultureName.Length > 0) { value = GetObjectInternal(resourceKey, CultureInfo.InvariantCulture.Name); } // If the value is still null and we're at the invariant culture // fallback to default resource provider if (value == null && string.IsNullOrEmpty(cultureName)) { IResourceProvider resxProvider; string typeName = "System.Web.Compilation.ResXResourceProviderFactory, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; ResourceProviderFactory factory = (ResourceProviderFactory)Activator.CreateInstance(Type.GetType(typeName)); if (FactoryType == ResxFactoryType.Global) { resxProvider = factory.CreateGlobalResourceProvider(originalClassName); } else { resxProvider = factory.CreateLocalResourceProvider(originalClassName); } value = resxProvider.GetObject(resourceKey, new CultureInfo(cultureName)); (_resourceCache[cultureName] as Dictionary <string, object>).Add(resourceKey, value); } Debug.WriteLine(resourceKey, "Key"); Debug.WriteLine(value, "Value"); Debug.WriteLine(className, "Path"); return(value); }
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); }
/// <summary> /// Avoid beforeFieldInit /// </summary> static LocalResourceManager() { LocalResXResourceProviderFactoryType = typeof(IResourceProvider).Assembly.GetType("System.Web.Compilation.ResXResourceProviderFactory", true); LocalResXResourceProviderType = typeof(IResourceProvider).Assembly.GetType("System.Web.Compilation.LocalResXResourceProvider", true); GetResourceProviderDelegate fnGetResourceProvider = null; ResourceProviderFactory rpf = null; SafeMethod glra = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fnGetResourceProvider = (GetResourceProviderDelegate)Delegate.CreateDelegate(typeof(GetResourceProviderDelegate), typeof(ResourceExpressionBuilder).GetMethod("GetLocalResourceProvider", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(TemplateControl) }, null)); rpf = (ResourceProviderFactory)Activator.CreateInstance(LocalResXResourceProviderFactoryType, true); glra = new SafeMethod(LocalResXResourceProviderType.GetMethod("GetLocalResourceAssembly", BindingFlags.Instance | BindingFlags.NonPublic)); }); getLocalResourceProvider = fnGetResourceProvider; LocalResXResourceProviderFactory = rpf; fnGetLocalResourceAssembly = glra; }
public ISettings Create() { var rp = new ResourceProviderFactory().Create(); return(new Settings(VSIXName, LiveFeedUrl.ToString(), RegistrySubKey, rp)); }
/// <summary> /// Ensures that there is a resource provider factory. /// </summary> private static void EnsureResourceProviderFactory() { if (_resourceProviderFactory == null) { _resourceProviderFactory = new ResourceProviderFactory(); } }