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


C# PolicyLevel.FromXml方法代码示例

本文整理汇总了C#中System.Security.Policy.PolicyLevel.FromXml方法的典型用法代码示例。如果您正苦于以下问题:C# PolicyLevel.FromXml方法的具体用法?C# PolicyLevel.FromXml怎么用?C# PolicyLevel.FromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Policy.PolicyLevel的用法示例。


在下文中一共展示了PolicyLevel.FromXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadPolicyLevelFromStringHelper

 private static PolicyLevel LoadPolicyLevelFromStringHelper(string str, string path, PolicyLevelType type)
 {
     if (str == null)
     {
         throw new ArgumentNullException("str");
     }
     PolicyLevel level = new PolicyLevel(type, path);
     SecurityElement topElement = new Parser(str).GetTopElement();
     if (topElement == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), new object[] { "configuration" }));
     }
     SecurityElement element2 = topElement.SearchForChildByTag("mscorlib");
     if (element2 == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), new object[] { "mscorlib" }));
     }
     SecurityElement element3 = element2.SearchForChildByTag("security");
     if (element3 == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), new object[] { "security" }));
     }
     SecurityElement element4 = element3.SearchForChildByTag("policy");
     if (element4 == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), new object[] { "policy" }));
     }
     SecurityElement e = element4.SearchForChildByTag("PolicyLevel");
     if (e == null)
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Policy_BadXml"), new object[] { "PolicyLevel" }));
     }
     level.FromXml(e);
     return level;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:SecurityManager.cs

示例2: LoadPolicyLevelFromStringHelper

        private static PolicyLevel LoadPolicyLevelFromStringHelper (string str, string path, PolicyLevelType type)
        {
            if (str == null)
                throw new ArgumentNullException( "str" );
            Contract.EndContractBlock();

            PolicyLevel level = new PolicyLevel(type, path);

            Parser parser = new Parser( str );
            SecurityElement elRoot = parser.GetTopElement();
            if (elRoot == null)
                throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Policy_BadXml" ), "configuration" ) );

            SecurityElement elMscorlib = elRoot.SearchForChildByTag( "mscorlib" );
            if (elMscorlib == null)
                throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Policy_BadXml" ), "mscorlib" ) );

            SecurityElement elSecurity = elMscorlib.SearchForChildByTag( "security" );
            if (elSecurity == null)
                throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Policy_BadXml" ), "security" ) );

            SecurityElement elPolicy = elSecurity.SearchForChildByTag( "policy" );
            if (elPolicy == null)
                throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Policy_BadXml" ), "policy" ) );

            SecurityElement elPolicyLevel = elPolicy.SearchForChildByTag( "PolicyLevel" );
            if (elPolicyLevel != null)
                level.FromXml( elPolicyLevel );
            else
                throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString( "Policy_BadXml" ), "PolicyLevel" ) );

            return level;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:33,代码来源:SecurityManager.cs

示例3: LoadPolicyLevelFromString

        static public PolicyLevel LoadPolicyLevelFromString( String str, PolicyLevelType type )
        {
#if _DEBUG
            if (debug)
            {
                DEBUG_OUT( "Input string =" );
                DEBUG_OUT( str );
            }
#endif 

            if (str == null)
                throw new ArgumentNullException( "str" );

            String name = Enum.GetName( typeof( PolicyLevelType ), type );

            if (name == null)
                return null;

            Parser parser = new Parser( str );

            PolicyLevel level = new PolicyLevel( name, ConfigId.None, type == PolicyLevelType.Machine );

            SecurityElement elRoot = parser.GetTopElement();
            
            if (elRoot == null)
            {
                throw new ArgumentException( String.Format( Environment.GetResourceString( "Policy_BadXml" ), "configuration" ) );
            }
            
            SecurityElement elMscorlib = elRoot.SearchForChildByTag( "mscorlib" );
            
            if (elMscorlib == null)
            {
                throw new ArgumentException( String.Format( Environment.GetResourceString( "Policy_BadXml" ), "mscorlib" ) );
            }
            
            SecurityElement elSecurity = elMscorlib.SearchForChildByTag( "security" );

            if (elSecurity == null)
            {
                throw new ArgumentException( String.Format( Environment.GetResourceString( "Policy_BadXml" ), "security" ) );
            }

            SecurityElement elPolicy = elSecurity.SearchForChildByTag( "policy" );
                
            if (elPolicy == null)
            {
                throw new ArgumentException( String.Format( Environment.GetResourceString( "Policy_BadXml" ), "policy" ) );
            }

            SecurityElement elPolicyLevel = elPolicy.SearchForChildByTag( "PolicyLevel" );
            
            if (elPolicyLevel != null)
            {
                level.FromXml( elPolicyLevel );
            }
            else
            {
                throw new ArgumentException( String.Format( Environment.GetResourceString( "Policy_BadXml" ), "PolicyLevel" ) );
            }

            level.Loaded = true; 

            return level;
        }
开发者ID:ArildF,项目名称:masters,代码行数:65,代码来源:securitymanager.cs


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