本文整理汇总了C#中IPermission.ToXml方法的典型用法代码示例。如果您正苦于以下问题:C# IPermission.ToXml方法的具体用法?C# IPermission.ToXml怎么用?C# IPermission.ToXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPermission
的用法示例。
在下文中一共展示了IPermission.ToXml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FrameDescHelper
private static bool FrameDescHelper(FrameSecurityDescriptor secDesc,
IPermission demand,
PermissionToken permToken)
{
PermissionSet permSet;
// If the demand is null, there is no need to continue
if (demand == null || demand.IsSubsetOf( null ))
return StackHalt;
// NOTE: See notes about exceptions and exception handling in FrameDescSetHelper
// Check Reduction
try
{
permSet = secDesc.GetPermitOnly();
if (permSet != null)
{
IPermission perm = permSet.GetPermission(demand);
#if _DEBUG
if (debug)
{
DEBUG_OUT("Checking PermitOnly");
DEBUG_OUT("permit only set =\n" + permSet.ToXml().ToString() );
DEBUG_OUT("demand =\n" + ((CodeAccessPermission)demand).ToXml().ToString() );
}
#endif
// If the permit only set does not contain the demanded permission, throw a security exception
if (perm == null)
{
if(!(demand is IUnrestrictedPermission && permSet.IsUnrestricted()))
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
else
{
if (!demand.IsSubsetOf( perm ))
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
}
}
catch (Exception)
{
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
// Check Denials
try
{
permSet = secDesc.GetDenials();
if (permSet != null)
{
#if _DEBUG
if (debug)
{
DEBUG_OUT("Checking Denials");
DEBUG_OUT("denied set =\n" + permSet.ToXml().ToString() );
}
#endif
IPermission perm = permSet.GetPermission(demand);
// If the deny set does contain the demanded permission, throw a security exception
if ((perm != null && perm.Intersect( demand ) != null) || (demand is IUnrestrictedPermission && permSet.IsUnrestricted()))
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
}
catch (Exception)
{
throw new SecurityException(String.Format(Environment.GetResourceString("Security_Generic"), demand.GetType().AssemblyQualifiedName), demand.GetType(), demand.ToXml().ToString());
}
if (secDesc.GetAssertAllPossible())
{
return StackHalt;
}
try
{
permSet = secDesc.GetAssertions();
// Check Assertions
if (permSet != null)
{
#if _DEBUG
if (debug)
DEBUG_OUT("Checking Assertions");
#endif
IPermission perm = permSet.GetPermission(demand);
// If the assert set does contain the demanded permission, halt the stackwalk
if ((perm != null && (demand.IsSubsetOf( perm )) || (demand is IUnrestrictedPermission && permSet.IsUnrestricted())))
{
#if _DEBUG
if (debug)
//.........这里部分代码省略.........