本文整理汇总了C#中System.Security.Permissions.FileIOPermission.IsUnrestricted方法的典型用法代码示例。如果您正苦于以下问题:C# FileIOPermission.IsUnrestricted方法的具体用法?C# FileIOPermission.IsUnrestricted怎么用?C# FileIOPermission.IsUnrestricted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Permissions.FileIOPermission
的用法示例。
在下文中一共展示了FileIOPermission.IsUnrestricted方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConstructorPermissionState
public void ConstructorPermissionState ()
{
p = new FileIOPermission(PermissionState.None);
Assert.AreEqual(false, p.IsUnrestricted(), "Should be Restricted");
p = new FileIOPermission(PermissionState.Unrestricted);
Assert.AreEqual(true, p.IsUnrestricted(), "Should be Unrestricted");
try{
p = new FileIOPermission((PermissionState)77);
Assert.Fail("Should have thrown an exception on invalid PermissionState");
}
catch{
// we should be here if things are working. nothing to do
}
}
示例2: FromXML
public void FromXML ()
{
p = new FileIOPermission(PermissionState.None);
SecurityElement esd = new SecurityElement("IPermission");
esd.AddAttribute("class", "FileIOPermission");
esd.AddAttribute("version", "1");
esd.AddAttribute("Unrestricted", "true");
p.FromXml(esd);
Assert.IsTrue(p.IsUnrestricted(), "Should get an unrestricted permission");
esd = new SecurityElement("IPermission");
esd.AddAttribute("class", "FileIOPermission");
esd.AddAttribute("version", "1");
// FIXME: Adjust to run on Mac OS's
if (Path.VolumeSeparatorChar == ':') {
esd.AddAttribute("Read", "c:\\temp;d:\\temp2");
esd.AddAttribute("Write", "c:\\temp;d:\\temp2;z:\\temp3");
}
else {
esd.AddAttribute("Read", "/temp;/usr/temp2");
esd.AddAttribute("Write", "/temp;/usr/temp2;/usr/bin/temp3");
}
p = new FileIOPermission(PermissionState.None);
p.FromXml(esd);
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Read);
Assert.IsTrue(pathsInPermission.Length == 2, "Path list should have 2 for Read");
pathsInPermission = p.GetPathList(FileIOPermissionAccess.Write);
Assert.IsTrue(pathsInPermission.Length == 3, "Path list should have 2 for Write");
}
示例3: GetFileIOPermission
private static string GetFileIOPermission (FileIOPermission ep)
{
if (ep.IsUnrestricted ())
return " FileIOPermission - Unrestricted\\l";
StringBuilder sb = new StringBuilder (" FileIOPermission\\l");
/* string[] list = ep.GetPathList (FileIOPermissionAccess.PathDiscovery);
if ((list != null) && (list.Length > 0)) {
sb.AppendFormat (" PathDiscovery: {0}\\l", s);
}
s = ep.GetPathList (FileIOPermissionAccess.Read);
if ((s != null) && (s.Length > 0))
sb.AppendFormat (" Read: {0}\\l", s);
s = ep.GetPathList (FileIOPermissionAccess.Write);
if ((s != null) && (s.Length > 0))
sb.AppendFormat (" Write: {0}\\l", s);
s = ep.GetPathList (FileIOPermissionAccess.Append);
if ((s != null) && (s.Length > 0))
sb.AppendFormat (" Append: {0}\\l", s);*/
return sb.ToString ();
}