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; }
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"); }
public void HostProtection () { HostProtectionAttribute hpa = new HostProtectionAttribute (); // internal permission IPermission p = hpa.CreatePermission (); Assert.AreEqual (9, GetTokenIndex (p)); }