Exemplo n.º 1
0
        private static MasterCategoryList Resolve(MasterCategoryList client, MasterCategoryList server, MasterCategoryList original)
        {
            MasterCategoryList masterCategoryList = new MasterCategoryList();

            masterCategoryList.SetProperties(MasterCategoryList.ResolveProperties(client.propertyBag, server.propertyBag, original.propertyBag, AcrProfile.MasterCategoryListProfile));
            HashSet <Category> hashSet = new HashSet <Category>(server.Count);

            Util.AddRange <Category, Category>(hashSet, server);
            foreach (Category category in client)
            {
                Category category2 = server.FindMatch(category);
                Category original2 = original.FindMatch(category);
                Category category3 = Category.Resolve(category, category2, original2);
                if (category3 != null && masterCategoryList.FindMatch(category3) == null)
                {
                    masterCategoryList.Add(category3);
                }
                if (category2 != null)
                {
                    hashSet.Remove(category2);
                }
            }
            foreach (Category category4 in hashSet)
            {
                Category original3 = original.FindMatch(category4);
                Category category5 = Category.Resolve(null, category4, original3);
                if (category5 != null && masterCategoryList.FindMatch(category5) == null)
                {
                    masterCategoryList.Add(category5);
                }
            }
            return(masterCategoryList);
        }
Exemplo n.º 2
0
        private void CopyOrOverrideAttributes(XmlWriter xmlWriter, IEnumerable <PropValue> propValueOverrides)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            Util.AddRange <KeyValuePair <string, object>, KeyValuePair <string, object> >(dictionary, MasterCategoryListSerializer.PropValuesToAttributeNameValues(propValueOverrides));
            while (this.xmlReader.MoveToNextAttribute())
            {
                if (this.IsFromCategoriesNamespace())
                {
                    object value;
                    if (dictionary.TryGetValue(this.xmlReader.LocalName, out value))
                    {
                        dictionary.Remove(this.xmlReader.LocalName);
                        MasterCategoryListSerializer.WriteAttributeForProperty(xmlWriter, this.xmlReader.LocalName, value);
                    }
                    else
                    {
                        xmlWriter.WriteAttributeString(this.xmlReader.LocalName, this.xmlReader.Value);
                    }
                }
                else
                {
                    xmlWriter.WriteAttributeString(this.xmlReader.Prefix, this.xmlReader.LocalName, this.xmlReader.NamespaceURI, this.xmlReader.Value);
                }
            }
            MasterCategoryListSerializer.WriteAttributesForProperties(xmlWriter, dictionary);
            this.xmlReader.MoveToElement();
        }
Exemplo n.º 3
0
            private static ForwardOnlyFilteredReader.PropertySetMixer GetPropertySets(params PropertyDefinition[] propertiesToReturn)
            {
                List <PropertyDefinition> list = new List <PropertyDefinition>();

                list.Add(ContactsFolder.AnrContactsReader.idProperty);
                list.AddRange(ContactsFolder.AnrCriteria.AnrProperties.Cast <PropertyDefinition>());
                Util.AddRange <PropertyDefinition, ContactEmailSlotParticipantProperty>(list, ContactEmailSlotParticipantProperty.AllInstances.Values);
                list.AddRange(ContactsFolder.AnrContactsReader.additionalProperties);
                ForwardOnlyFilteredReader.PropertySetMixer propertySetMixer = new ForwardOnlyFilteredReader.PropertySetMixer();
                propertySetMixer.AddSet(ForwardOnlyFilteredReader.PropertySet.Identification, new PropertyDefinition[]
                {
                    ContactsFolder.AnrContactsReader.idProperty
                });
                propertySetMixer.AddSet(ForwardOnlyFilteredReader.PropertySet.ForFilter, list.ToArray());
                propertySetMixer.AddSet(ForwardOnlyFilteredReader.PropertySet.Requested, propertiesToReturn);
                return(propertySetMixer);
            }
Exemplo n.º 4
0
        private bool CultureWillFit(CultureInfo newCulture)
        {
            if (this.cultures.Contains(newCulture))
            {
                return(true);
            }
            ADUser aduser = new ADUser();

            try
            {
                Util.AddRange <CultureInfo, CultureInfo>(aduser.Languages, this.cultures);
                aduser.Languages.Add(newCulture);
            }
            catch (DataValidationException ex)
            {
                if (ex.Error is PropertyConstraintViolationError)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 5
0
 private void MovePersistentContent(MasterCategoryList sourceMcl)
 {
     if (this == sourceMcl)
     {
         List <Category> list = new List <Category>(this.Count);
         foreach (Category category in this)
         {
             list.Add(category.Clone());
         }
         this.Clear();
         Util.AddRange <Category, Category>(this, list);
         return;
     }
     this.Clear();
     foreach (Category category2 in sourceMcl.categories.Values)
     {
         category2.Detach();
         this.Add(category2);
     }
     sourceMcl.categories.Clear();
     this.propertyBag      = sourceMcl.propertyBag;
     sourceMcl.propertyBag = new MemoryPropertyBag();
 }
Exemplo n.º 6
0
 internal void SerializeUsingSource(MasterCategoryList mcl, XmlWriter xmlWriter)
 {
     MasterCategoryListSerializer.CatchSerializationException(delegate
     {
         bool flag = false;
         HashSet <Category> hashSet = new HashSet <Category>(mcl.Count);
         Util.AddRange <Category, Category>(hashSet, mcl);
         this.xmlReader.Read();
         while (!this.xmlReader.EOF)
         {
             if (this.xmlReader.NodeType == XmlNodeType.Element && this.IsFromCategoriesNamespace())
             {
                 this.EnsureLocationIsExpectedForKnownElements(flag);
                 string localName;
                 if ((localName = this.xmlReader.LocalName) != null)
                 {
                     if (localName == "categories")
                     {
                         xmlWriter.WriteStartElement(this.xmlReader.Prefix, this.xmlReader.LocalName, this.xmlReader.NamespaceURI);
                         this.CopyOrOverrideAttributes(xmlWriter, MasterCategoryListSerializer.GetProperties(new MasterCategoryListSerializer.TryGetPropertyDelegate(mcl.TryGetProperty), MasterCategoryListSchema.Instance.AllProperties));
                         flag = true;
                         if (this.xmlReader.IsEmptyElement)
                         {
                             MasterCategoryListSerializer.WriteCategoryElements(xmlWriter, hashSet);
                             xmlWriter.WriteEndElement();
                         }
                         this.xmlReader.Read();
                         continue;
                     }
                     if (localName == "category")
                     {
                         Category category = this.FindMatchingCategory(mcl);
                         if (category != null && hashSet.Contains(category))
                         {
                             xmlWriter.WriteStartElement(this.xmlReader.Prefix, this.xmlReader.LocalName, this.xmlReader.NamespaceURI);
                             this.CopyOrOverrideAttributes(xmlWriter, MasterCategoryListSerializer.GetProperties(new MasterCategoryListSerializer.TryGetPropertyDelegate(category.TryGetProperty), CategorySchema.Instance.AllProperties));
                             if (this.xmlReader.IsEmptyElement)
                             {
                                 xmlWriter.WriteEndElement();
                                 this.xmlReader.Skip();
                             }
                             else
                             {
                                 this.xmlReader.Read();
                                 int depth = this.xmlReader.Depth;
                                 while (this.xmlReader.Depth >= depth)
                                 {
                                     xmlWriter.WriteNode(this.xmlReader, false);
                                 }
                             }
                             hashSet.Remove(category);
                             continue;
                         }
                         this.xmlReader.Skip();
                         continue;
                     }
                 }
                 xmlWriter.WriteNode(this.xmlReader, false);
             }
             else if (this.xmlReader.NodeType == XmlNodeType.EndElement && this.xmlReader.LocalName == "categories")
             {
                 MasterCategoryListSerializer.WriteCategoryElements(xmlWriter, hashSet);
                 xmlWriter.WriteNode(this.xmlReader, false);
             }
             else
             {
                 xmlWriter.WriteNode(this.xmlReader, false);
             }
         }
         if (!flag)
         {
             if (hashSet.Count > 0)
             {
                 ExTraceGlobals.StorageTracer.TraceDebug((long)mcl.GetHashCode(), "The source XML didn't contain the root element we expect. Reverting to source-less serialization.");
                 throw new CorruptDataException(ServerStrings.ExInvalidMclXml);
             }
             this.ReportFault();
         }
     });
 }