// Token: 0x06001DFA RID: 7674 RVA: 0x000ADA28 File Offset: 0x000ABC28
        private void LoadPagedSearch(int startRange, int itemCount, PropertyDefinition[] properties, bool retry)
        {
            int num = startRange;

            if (!string.IsNullOrEmpty(this.cookie))
            {
                num = startRange - (this.cookieIndex + 1);
            }
            int itemsToSkip = num;

            object[][] array;
            int        num2;

            if (DirectoryAssistance.IsEmptyAddressList(this.userContext))
            {
                array = new object[0][];
                num2  = 0;
            }
            else
            {
                array = AddressBookBase.PagedSearch(DirectoryAssistance.IsVirtualAddressList(this.userContext) ? this.userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN : null, DirectoryAssistance.IsVirtualAddressList(this.userContext) ? null : this.addressBookBase, this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, AddressBookBase.RecipientCategory.All, this.searchString, itemsToSkip, ref this.cookie, itemCount, out num2, ref this.lcid, ref this.preferredDC, properties);
            }
            if (array.Length > 0)
            {
                base.StartRange  = startRange;
                base.EndRange    = base.StartRange + (array.Length - 1);
                this.cookieIndex = base.EndRange;
                base.Items       = array;
                return;
            }
            if (this.cookie != null && this.cookie.Length != 0 && retry)
            {
                this.cookieIndex = 0;
                this.LoadPagedSearch(0, itemCount, properties, false);
                return;
            }
            if (num2 != 0 && retry)
            {
                if (this.cookieIndex > 0)
                {
                    num2 += this.cookieIndex + 1;
                }
                int num3 = num2 - 1;
                startRange = num3 - (itemCount - 1);
                if (startRange < 0)
                {
                    startRange = 0;
                }
                this.cookie      = null;
                this.cookieIndex = 0;
                this.lcid        = Culture.GetUserCulture().LCID;
                this.LoadPagedSearch(startRange, itemCount, properties, false);
                return;
            }
            base.StartRange  = int.MinValue;
            base.EndRange    = int.MinValue;
            this.cookie      = null;
            this.cookieIndex = 0;
            base.Items       = array;
        }
        public override void LoadData(int startRange, int endRange)
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "ADDataSource.LoadData(Start)");
            int    lcid        = Culture.GetUserCulture().LCID;
            string preferredDC = this.userContext.PreferredDC;

            ExTraceGlobals.MailCallTracer.TraceDebug <string>((long)this.GetHashCode(), "AddressBookDataSource.LoadData: preferred DC in user context = '{0}'", preferredDC);
            if (startRange < 1)
            {
                throw new ArgumentOutOfRangeException("startRange", "startRange must be greater than 0");
            }
            if (endRange < startRange)
            {
                throw new ArgumentOutOfRangeException("endRange", "endRange must be greater than or equal to startRange");
            }
            PropertyDefinition[] properties = base.CreateProperyTable();
            int    num         = endRange - startRange + 1;
            int    pagesToSkip = startRange / num;
            string cookie      = null;

            if (DirectoryAssistance.IsEmptyAddressList(this.userContext))
            {
                base.Items = new object[0][];
            }
            else if (!string.IsNullOrEmpty(this.searchString))
            {
                base.Items = AddressBookBase.PagedSearch(DirectoryAssistance.IsVirtualAddressList(this.userContext) ? this.userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN : null, DirectoryAssistance.IsVirtualAddressList(this.userContext) ? null : this.addressBook, this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.recipientCategory, this.searchString, ref cookie, pagesToSkip, num, out this.itemsTouched, ref lcid, ref preferredDC, properties);
            }
            else
            {
                ExTraceGlobals.MailCallTracer.TraceDebug <OrganizationId>((long)this.GetHashCode(), "AddressBookDataSource.LoadData: browse: OrganizationId of address book = '{0}'", this.addressBook.OrganizationId);
                int num2;
                base.Items = this.addressBook.BrowseTo(ref cookie, this.userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN, ref lcid, ref preferredDC, startRange, num + 1, out num2, DirectoryAssistance.IsVirtualAddressList(this.userContext), properties);
                if (base.Items != null && base.Items.Length < num + 1)
                {
                    cookie = null;
                }
            }
            this.userContext.PreferredDC = preferredDC;
            ExTraceGlobals.MailCallTracer.TraceDebug <string>((long)this.GetHashCode(), "AddressBookDataSource.LoadData: stamped preferred DC = '{0}' onto user context.", preferredDC);
            base.Cookie     = cookie;
            base.StartRange = startRange;
            if (base.Items == null || base.Items.Length == 0)
            {
                base.EndRange = 0;
                return;
            }
            if (base.Items.Length < num)
            {
                base.EndRange = startRange + base.Items.Length - 1;
                return;
            }
            base.EndRange = endRange;
        }