本文整理汇总了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;
}
示例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;
}
示例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;
}