CreatePermission() публичный Метод

public CreatePermission ( ) : IPermission
Результат IPermission
Пример #1
0
        internal static TypeConverter GetConverter(Type type) { 
            HostProtectionAttribute protAttrib = new HostProtectionAttribute();
            protAttrib.SharedState = true;

            CodeAccessPermission permission = (CodeAccessPermission)protAttrib.CreatePermission();
            permission.Assert(); 
            try {
                return TypeDescriptor.GetConverter(type);
            }
            finally {
                CodeAccessPermission.RevertAssert(); 
            }
        }
 internal static TypeConverter GetConverter(Type type)
 {
     TypeConverter converter;
     HostProtectionAttribute attribute = new HostProtectionAttribute {
         SharedState = true
     };
     ((CodeAccessPermission) attribute.CreatePermission()).Assert();
     try
     {
         converter = TypeDescriptor.GetConverter(type);
     }
     finally
     {
         CodeAccessPermission.RevertAssert();
     }
     return converter;
 }
Пример #3
0
		private void DefaultTests (HostProtectionAttribute hpa)
		{
			Assert.AreEqual (SecurityAction.LinkDemand, hpa.Action, "Action");
			Assert.AreEqual (HostProtectionResource.None, hpa.Resources, "Resources");
			Assert.IsFalse (hpa.ExternalProcessMgmt, "ExternalProcessMgmt");
			Assert.IsFalse (hpa.ExternalThreading, "ExternalThreading");
			Assert.IsFalse (hpa.MayLeakOnAbort, "MayLeakOnAbort");
			Assert.IsFalse (hpa.SecurityInfrastructure, "SecurityInfrastructure");
			Assert.IsFalse (hpa.SelfAffectingProcessMgmt, "SelfAffectingProcessMgmt");
			Assert.IsFalse (hpa.SelfAffectingThreading, "SelfAffectingThreading");
			Assert.IsFalse (hpa.SharedState, "SharedState");
			Assert.IsFalse (hpa.Synchronization, "Synchronization");
			Assert.IsFalse (hpa.UI, "UI");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted");
			IPermission p = hpa.CreatePermission ();
			Assert.AreEqual ("System.Security.Permissions.HostProtectionPermission", p.GetType ().ToString (), "CreatePermission");
			Assert.IsTrue ((p is IUnrestrictedPermission), "IUnrestrictedPermission");
		}
Пример #4
0
		public void HostProtection ()
		{
			HostProtectionAttribute hpa = new HostProtectionAttribute ();
			// internal permission
			IPermission p = hpa.CreatePermission ();
			Assert.AreEqual (9, GetTokenIndex (p));
		}