/// <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; }
/// <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; }