System.Configuration.TypeUtil.IsTypeAllowedInConfig C# (CSharp) Метод

IsTypeAllowedInConfig() статический приватный Метод

static private IsTypeAllowedInConfig ( Type t ) : bool
t System.Type
Результат bool
        internal static bool IsTypeAllowedInConfig(Type t) {
            // Note:
            // This code is copied from HttpRuntime.IsTypeAllowedInConfig, but modified in
            // how it checks for fulltrust this can be called from non-ASP.NET apps.
            
            // Allow everything in full trust
            if (IsCallerFullTrust) {
                return true;
            }
            
            Assembly assembly = t.Assembly;
            if (!assembly.GlobalAssemblyCache)
                return true;

            // If it has the APTCA bit, allow it
            if (HasAptcaBit(assembly))
                return true;
        
            // It's a GAC type without APTCA in partial trust scenario: block it
            return false;
        }
    }

Usage Example

Пример #1
0
        private ProtectedConfigurationProvider InstantiateProvider(ProviderSettings pn)
        {
            Type t = TypeUtil.GetTypeWithReflectionPermission(pn.Type, true);

            if (!typeof(ProtectedConfigurationProvider).IsAssignableFrom(t))
            {
                throw new Exception(SR.GetString(SR.WrongType_of_Protected_provider));
            }

            if (!TypeUtil.IsTypeAllowedInConfig(t))
            {
                throw new Exception(SR.GetString(SR.Type_from_untrusted_assembly, t.FullName));
            }

            return(CreateAndInitializeProviderWithAssert(t, pn));
        }
All Usage Examples Of System.Configuration.TypeUtil::IsTypeAllowedInConfig