System.Security.SecurityManager.SecurityManager.LinkDemandSecurityException C# (CSharp) Method

LinkDemandSecurityException() private static method

private static LinkDemandSecurityException ( int securityViolation, IntPtr methodHandle ) : void
securityViolation int
methodHandle IntPtr
return void
		private static void LinkDemandSecurityException (int securityViolation, IntPtr methodHandle)
		{
			RuntimeMethodHandle runtimeHandle = new RuntimeMethodHandle (methodHandle);
			MethodInfo method = (MethodInfo)(MethodBase.GetMethodFromHandle (runtimeHandle));
			Assembly a = method.DeclaringType.Assembly;

			string message = null;
			AssemblyName an = null;
			PermissionSet granted = null;
			PermissionSet refused = null;
			object demanded = null;
			IPermission failed = null;

			if (a != null) {
				an = a.UnprotectedGetName ();
				granted = a.GrantedPermissionSet;
				refused = a.DeniedPermissionSet;
			}

			switch (securityViolation) {
			case 1: // MONO_JIT_LINKDEMAND_PERMISSION
				message = Locale.GetText ("Permissions refused to call this method.");
				break;
			case 2: // MONO_JIT_LINKDEMAND_APTC
				message = Locale.GetText ("Partially trusted callers aren't allowed to call into this assembly.");
				demanded = (object) DefaultPolicies.FullTrust; // immutable
				break;
			case 4: // MONO_JIT_LINKDEMAND_ECMA
				message = Locale.GetText ("Calling internal calls is restricted to ECMA signed assemblies.");
				break;
			case 8: // MONO_JIT_LINKDEMAND_PINVOKE
				message = Locale.GetText ("Calling unmanaged code isn't allowed from this assembly.");
				demanded = (object) _unmanagedCode;
				failed = _unmanagedCode;
				break;
			default:
				message = Locale.GetText ("JIT time LinkDemand failed.");
				break;
			}

			throw new SecurityException (message, an, granted, refused, method, SecurityAction.LinkDemand, demanded, failed, null);
		}