BuiltInGetToken() приватный Метод

private BuiltInGetToken ( int index, IPermission perm, Type cls ) : PermissionToken
index int
perm IPermission
cls System.Type
Результат PermissionToken
Пример #1
0
        [System.Security.SecurityCritical]  // auto-generated
        public static PermissionToken GetToken(Type cls)
        {
            if (cls == null)
            {
                return(null);
            }

#if FEATURE_CAS_POLICY
            if (cls.GetInterface("System.Security.Permissions.IBuiltInPermission") != null)
            {
                if (s_reflectPerm == null)
                {
                    s_reflectPerm = new ReflectionPermission(PermissionState.Unrestricted);
                }
                s_reflectPerm.Assert();
                MethodInfo method = cls.GetMethod("GetTokenIndex", BindingFlags.Static | BindingFlags.NonPublic);
                Contract.Assert(method != null, "IBuiltInPermission types should have a static method called 'GetTokenIndex'");

                // GetTokenIndex needs to be invoked without any security checks, since doing a security check
                // will involve a ReflectionTargetDemand which creates a CompressedStack and attempts to get the
                // token.
                RuntimeMethodInfo getTokenIndex = method as RuntimeMethodInfo;
                Contract.Assert(getTokenIndex != null, "method is not a RuntimeMethodInfo");
                int token = (int)getTokenIndex.UnsafeInvoke(null, BindingFlags.Default, null, null, null);
                return(s_theTokenFactory.BuiltInGetToken(token, null, cls));
            }
            else
#endif // FEATURE_CAS_POLICY
            {
                return(s_theTokenFactory.GetToken(cls, null));
            }
        }
Пример #2
0
        public static PermissionToken FindToken(Type cls)
        {
            if (cls == null)
            {
                return(null);
            }
            if (cls.GetInterface("System.Security.Permissions.IBuiltInPermission") == null)
            {
                return(s_theTokenFactory.FindToken(cls));
            }
            if (s_reflectPerm == null)
            {
                s_reflectPerm = new ReflectionPermission(PermissionState.Unrestricted);
            }
            s_reflectPerm.Assert();
            RuntimeMethodInfo method = cls.GetMethod("GetTokenIndex", BindingFlags.NonPublic | BindingFlags.Static) as RuntimeMethodInfo;
            int index = (int)method.Invoke(null, BindingFlags.Default, null, null, null, true);

            return(s_theTokenFactory.BuiltInGetToken(index, null, cls));
        }
Пример #3
0
        public static PermissionToken GetToken(Type cls)
        {
            if (cls == null)
            {
                return(null);
            }

            if (cls.GetInterface("System.Security.Permissions.IBuiltInPermission") != null)
            {
                if (s_reflectPerm == null)
                {
                    s_reflectPerm = new ReflectionPermission(PermissionState.Unrestricted);
                }
                s_reflectPerm.Assert();
                MethodInfo method = cls.GetMethod("GetTokenIndex", BindingFlags.Static | BindingFlags.NonPublic);
                BCLDebug.Assert(method != null, "IBuiltInPermission types should have a static method called 'GetTokenIndex'");
                return(s_theTokenFactory.BuiltInGetToken((int)method.Invoke(null, null), null, cls));
            }
            else
            {
                return(s_theTokenFactory.GetToken(cls, null));
            }
        }
Пример #4
0
        public static PermissionToken GetToken(IPermission perm)
        {
            if (perm == null)
            {
                return(null);
            }

            IBuiltInPermission ibPerm = perm as IBuiltInPermission;

            if (ibPerm != null)
            {
                return(s_theTokenFactory.BuiltInGetToken(ibPerm.GetTokenIndex(), perm, null));
            }
            else
            {
                return(s_theTokenFactory.GetToken(perm.GetType(), perm));
            }
        }