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

private GetToken ( String typeStr ) : PermissionToken
typeStr String
Результат 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 GetToken(Type cls)
        {
            if (cls == null)
            {
                return(null);
            }

            return(s_theTokenFactory.GetToken(cls, null));
        }
Пример #3
0
        public static PermissionToken GetToken(IPermission perm)
        {
            if (perm == null)
            {
                return(null);
            }
            IBuiltInPermission permission = perm as IBuiltInPermission;

            if (permission != null)
            {
                return(s_theTokenFactory.BuiltInGetToken(permission.GetTokenIndex(), perm, null));
            }
            return(s_theTokenFactory.GetToken(perm.GetType(), perm));
        }
Пример #4
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));
            }
        }