Beispiel #1
0
        internal PolicyKey[] AddSerializedPolicies(StreamReader reader)
        {
            if (policies == null)
            {
                policies = new PolicyDictionary();
            }
            var keys = new List <PolicyKey> ();

            foreach (ScopedPolicy policyPair in PolicyService.RawDeserializeXml(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 + "'");
                }
                keys.Add(key);
                policies[key] = policyPair.Policy;
                if (!policyPair.SupportsDiffSerialize)
                {
                    externalPolicies.Add(key);
                }
            }
            return(keys.ToArray());
        }
Beispiel #2
0
 internal void RemoveSerializedPolicies(StreamReader reader)
 {
     if (policies == null)
     {
         return;
     }
     // NOTE: this could be more efficient if it just got the types instead of a
     // full deserialisation
     foreach (ScopedPolicy policyPair in PolicyService.RawDeserializeXml(reader))
     {
         policies.Remove(new PolicyKey(policyPair.PolicyType, policyPair.Scope));
     }
 }