public FromXml ( SecurityElement e ) : void | ||
e | SecurityElement | |
Результат | void |
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; }
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; }
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; }