public static PermissionToken FindToken( 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.FindToken( cls );
}
}