internal void LoadFromXml(XmlReader reader) { if (policies == null) { policies = new PolicyDictionary(); } else { policies.Clear(); } reader.MoveToContent(); string str = reader.GetAttribute("name"); if (!string.IsNullOrEmpty(str)) { Name = str; } str = reader.GetAttribute("id"); if (!string.IsNullOrEmpty(str)) { Id = str; } reader.MoveToElement(); //note: can't use AddSerializedPolicies as we want diff serialisation foreach (ScopedPolicy policyPair in PolicyService.DiffDeserializeXml(reader)) { PolicyKey key = new PolicyKey(policyPair.PolicyType, policyPair.Scope); if (policies.ContainsKey(key)) { throw new InvalidOperationException( "Cannot add second policy of type '" + key + "' to policy set '" + Id + "'" ); } policies[key] = policyPair.Policy; } }
internal void LoadFromFile(StreamReader reader) { if (policies == null) { policies = new PolicyDictionary(); } else { policies.Clear(); } //note: can't use AddSerializedPolicies as we want diff serialisation foreach (ScopedPolicy policyPair in PolicyService.DiffDeserializeXml(reader)) { PolicyKey key = new PolicyKey(policyPair.PolicyType, policyPair.Scope); if (policies.ContainsKey(key)) { throw new InvalidOperationException("Cannot add second policy of type '" + key.ToString() + "' to policy set '" + Id + "'"); } policies[key] = policyPair.Policy; } }