CreatePermission() 공개 메소드

public CreatePermission ( ) : IPermission
리턴 IPermission
		public void Default () 
		{
			FileIOPermissionAttribute a = new FileIOPermissionAttribute (SecurityAction.Assert);
			Assert.IsNull (a.Append, "Append");
			Assert.IsNull (a.PathDiscovery, "PathDiscovery");
			Assert.IsNull (a.Read, "Read");
			Assert.IsNull (a.Write, "Write");
			Assert.IsNotNull (a.AllFiles, "AllFiles");
			Assert.IsNotNull (a.AllLocalFiles, "AllLocalFiles");
			Assert.IsNull (a.ChangeAccessControl, "ChangeAccessControl");
			Assert.IsNull (a.ViewAccessControl, "ViewAccessControl");

			Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId");
			Assert.IsFalse (a.Unrestricted, "Unrestricted");

			FileIOPermission perm = (FileIOPermission) a.CreatePermission ();
			Assert.AreEqual (FileIOPermissionAccess.NoAccess, perm.AllFiles, "CreatePermission-AllFiles");
			Assert.AreEqual (FileIOPermissionAccess.NoAccess, perm.AllLocalFiles, "CreatePermission-AllLocalFiles");
			Assert.IsFalse (perm.IsUnrestricted (), "perm-Unrestricted");
		}
		public void All () 
		{
			string filename = Assembly.GetCallingAssembly ().Location;
			FileIOPermissionAttribute attr = new FileIOPermissionAttribute (SecurityAction.Assert);
			attr.All = filename;
			Assert.AreEqual (filename, attr.Append, "All=Append");
			Assert.AreEqual (filename, attr.PathDiscovery, "All=PathDiscovery");
			Assert.AreEqual (filename, attr.Read, "All=Read");
			Assert.AreEqual (filename, attr.Write, "All=Write");
			Assert.IsNotNull (attr.AllFiles, "AllFiles");
			Assert.IsNotNull (attr.AllLocalFiles, "AllLocalFiles");
			Assert.IsNull (attr.ChangeAccessControl, "ChangeAccessControl");
			Assert.IsNull (attr.ViewAccessControl, "ViewAccessControl");
			FileIOPermission p = (FileIOPermission)attr.CreatePermission ();
			filename = Path.GetFullPath (filename);
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.Append) [0], "All=FileIOPermissionAttribute-Append");
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.PathDiscovery) [0], "All=FileIOPermissionAttribute-PathDiscovery");
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.Read) [0], "All=FileIOPermissionAttribute-Read");
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.Write) [0], "All=FileIOPermissionAttribute-Write");
		}
		public void Unrestricted () 
		{
			FileIOPermissionAttribute a = new FileIOPermissionAttribute (SecurityAction.Assert);
			a.Unrestricted = true;

			FileIOPermission perm = (FileIOPermission) a.CreatePermission ();
			Assert.IsTrue (perm.IsUnrestricted (), "CreatePermission.IsUnrestricted");
			Assert.AreEqual (FileIOPermissionAccess.AllAccess, perm.AllFiles, "CreatePermission.AllFiles");
			Assert.AreEqual (FileIOPermissionAccess.AllAccess, perm.AllLocalFiles, "CreatePermission.AllLocalFiles");
		}
		public void NonC14NPath ()
		{
			string filename = Path.Combine (Path.GetTempPath (), "test");
			filename = Path.Combine (filename, "..");
			filename = Path.Combine (filename, "here");
			FileIOPermissionAttribute attr = new FileIOPermissionAttribute (SecurityAction.Assert);
			// attribute class will keep the .. in the path
			attr.All = filename;
			Assert.AreEqual (filename, attr.Append, "All=Append");
			Assert.AreEqual (filename, attr.PathDiscovery, "All=PathDiscovery");
			Assert.AreEqual (filename, attr.Read, "All=Read");
			Assert.AreEqual (filename, attr.Write, "All=Write");
			// but the permission class will c14n it
			filename = Path.GetFullPath (filename);
			FileIOPermission p = (FileIOPermission)attr.CreatePermission ();
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.Append) [0], "All=FileIOPermissionAttribute-Append");
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.PathDiscovery) [0], "All=FileIOPermissionAttribute-PathDiscovery");
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.Read) [0], "All=FileIOPermissionAttribute-Read");
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.Write) [0], "All=FileIOPermissionAttribute-Write");
		}
		public void Write () 
		{
			string filename = Assembly.GetCallingAssembly ().Location;
			FileIOPermissionAttribute attr = new FileIOPermissionAttribute (SecurityAction.Assert);
			attr.Write = filename;
			Assert.IsNull (attr.Append, "Append=null");
			Assert.IsNull (attr.PathDiscovery, "PathDiscovery=null");
			Assert.IsNull (attr.Read, "Read=null");
			Assert.AreEqual (filename, attr.Write, "Write=Write");
			FileIOPermission p = (FileIOPermission) attr.CreatePermission ();
			filename = Path.GetFullPath (filename);
			Assert.IsNull (p.GetPathList (FileIOPermissionAccess.Append), "PathDiscovery=FileIOPermissionAttribute-Append");
			Assert.IsNull (p.GetPathList (FileIOPermissionAccess.PathDiscovery), "PathDiscovery=FileIOPermissionAttribute-PathDiscovery");
			Assert.IsNull (p.GetPathList (FileIOPermissionAccess.Read), "PathDiscovery=FileIOPermissionAttribute-Read");
			Assert.AreEqual (filename, p.GetPathList (FileIOPermissionAccess.Write) [0], "PathDiscovery=FileIOPermissionAttribute-Write");
		}