public IEnumerator <IStorePropertyBag> GetEnumerator()
        {
            ContactFoldersEnumeratorOptions foldersEnumeratorOptions = ContactFoldersEnumeratorOptions.SkipHiddenFolders | ContactFoldersEnumeratorOptions.SkipDeletedFolders | ContactFoldersEnumeratorOptions.IncludeParentFolder;
            ContactFoldersEnumerator        foldersEnumerator        = new ContactFoldersEnumerator(this.session, new XSOFactory(), this.folderType, foldersEnumeratorOptions, new PropertyDefinition[0]);

            foreach (IStorePropertyBag folderPropertyBag in foldersEnumerator)
            {
                VersionedId folderId = folderPropertyBag.GetValueOrDefault <VersionedId>(FolderSchema.Id, null);
                IFolder     folder;
                try
                {
                    folder = this.xsoFactory.BindToFolder(this.session, folderId.ObjectId);
                }
                catch (ObjectNotFoundException)
                {
                    RecursiveContactsEnumerator.Tracer.TraceError <VersionedId, Guid>((long)this.GetHashCode(), "Failed to bind to folder. FolderId: {0}. Mailbox: {1}.", folderId, this.session.MailboxOwner.MailboxInfo.MailboxGuid);
                    continue;
                }
                try
                {
                    using (IQueryResult contactsQuery = folder.IItemQuery(ItemQueryType.None, null, null, this.properties))
                    {
                        IStorePropertyBag[] contacts = contactsQuery.GetPropertyBags(100);
                        while (contacts.Length > 0)
                        {
                            foreach (IStorePropertyBag contactPropertyBag in contacts)
                            {
                                if (contactPropertyBag != null && !(contactPropertyBag.TryGetProperty(ItemSchema.Id) is PropertyError) && ObjectClass.IsContact(contactPropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, null)))
                                {
                                    yield return(contactPropertyBag);
                                }
                            }
                            contacts = contactsQuery.GetPropertyBags(100);
                        }
                    }
                }
                finally
                {
                    folder.Dispose();
                }
            }
            yield break;
        }
Ejemplo n.º 2
0
 public ContactFoldersEnumerator(IMailboxSession session, IXSOFactory xsoFactory, ContactFoldersEnumeratorOptions enumerateOptions, params PropertyDefinition[] additionalProperties) : this(session, xsoFactory, DefaultFolderType.Root, enumerateOptions, additionalProperties)
 {
 }
Ejemplo n.º 3
0
 public ContactFoldersEnumerator(IMailboxSession session, IXSOFactory xsoFactory, DefaultFolderType parentFolderScope, ContactFoldersEnumeratorOptions enumerateOptions, params PropertyDefinition[] additionalProperties)
 {
     Util.ThrowOnNullArgument(session, "session");
     Util.ThrowOnNullArgument(xsoFactory, "xsoFactory");
     EnumValidator.ThrowIfInvalid <ContactFoldersEnumeratorOptions>(enumerateOptions, "enumerateOptions");
     this.session              = session;
     this.xsoFactory           = xsoFactory;
     this.enumerateOptions     = enumerateOptions;
     this.additionalProperties = additionalProperties;
     this.parentFolderScope    = ((parentFolderScope != DefaultFolderType.None) ? parentFolderScope : DefaultFolderType.Root);
 }
Ejemplo n.º 4
0
 public ContactFoldersEnumerator(IMailboxSession session, ContactFoldersEnumeratorOptions enumerateOptions) : this(session, new XSOFactory(), enumerateOptions, new PropertyDefinition[0])
 {
 }