当前位置: 首页>>代码示例>>C#>>正文


C# IPermission.ToXml方法代码示例

本文整理汇总了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)
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:securityruntime.cs


注:本文中的IPermission.ToXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。