// Token: 0x06001A7C RID: 6780 RVA: 0x0006EDA4 File Offset: 0x0006CFA4
        public virtual IEnumerable <TRecipient> ExpandGroup <TRecipient>(IADDistributionList group) where TRecipient : MiniRecipient, new()
        {
            if (group == null)
            {
                throw new ArgumentNullException("group");
            }
            if (ADRecipientCache <TEntry> .PerfCounters != null)
            {
                ADRecipientCache <TEntry> .PerfCounters.ExpandGroupRequestsTotal.Increment();

                ADRecipientCache <TEntry> .PerfCounters.RequestsPendingTotal.Increment();
            }
            try
            {
                foreach (TRecipient entry in group.Expand <TRecipient>(1000, this.properties))
                {
                    yield return(entry);
                }
            }
            finally
            {
                ADRecipientCache <TEntry> .DecrementPendingRequestsCounter();
            }
            yield break;
        }
        // Token: 0x06001A8E RID: 6798 RVA: 0x0006F320 File Offset: 0x0006D520
        private Result <TEntry> LookUpRecipientInAD(ProxyAddress proxyAddress, ADPropertyDefinition[] properties)
        {
            if (ADRecipientCache <TEntry> .PerfCounters != null)
            {
                ADRecipientCache <TEntry> .PerfCounters.IndividualAddressLookupsTotal.Increment();

                ADRecipientCache <TEntry> .PerfCounters.RequestsPendingTotal.Increment();

                ADRecipientCache <TEntry> .PerfCounters.AggregateLookupsTotal.Increment();

                this.IncrementQueriesPerCacheCounter();
            }
            ComponentTrace <ADRecipientCacheTags> .TraceDebug <ProxyAddress>(0, -1L, "Lookup recipient {0}", proxyAddress);

            TEntry    entry     = default(TEntry);
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                ADNotificationAdapter.RunADOperation(delegate()
                {
                    if (typeof(TEntry) == typeof(ADRawEntry))
                    {
                        entry = (TEntry)((object)this.ADSession.FindByProxyAddress(proxyAddress, properties));
                        return;
                    }
                    if (typeof(TEntry) == typeof(TransportMiniRecipient))
                    {
                        entry = (this.ADSession.FindByProxyAddress <TransportMiniRecipient>(proxyAddress) as TEntry);
                        return;
                    }
                    throw new NotSupportedException();
                });
                if (entry == null)
                {
                    return(new Result <TEntry>(default(TEntry), ProviderError.NotFound));
                }
            }
            catch (DataValidationException ex)
            {
                ComponentTrace <ADRecipientCacheTags> .TraceError <DataValidationException>(0, -1L, "DataValidationException: {0}", ex);

                return(new Result <TEntry>(default(TEntry), ex.Error));
            }
            finally
            {
                stopwatch.Stop();
                if (ADRecipientCache <TEntry> .PerfCounters != null)
                {
                    ADRecipientCache <TEntry> .PerfCounters.AverageLookupQueryLatency.IncrementBy(stopwatch.ElapsedMilliseconds);
                }
                ADRecipientCache <TEntry> .DecrementPendingRequestsCounter();
            }
            return(new Result <TEntry>(entry, null));
        }
        // Token: 0x06001A77 RID: 6775 RVA: 0x0006E6D4 File Offset: 0x0006C8D4
        public virtual IList <Result <TEntry> > FindAndCacheRecipients(IList <ProxyAddress> proxyAddressList)
        {
            if (proxyAddressList == null)
            {
                throw new ArgumentNullException("proxyAddressList");
            }
            List <Result <TEntry> > list    = new List <Result <TEntry> >(proxyAddressList.Count);
            List <ProxyAddress>     proxies = new List <ProxyAddress>(proxyAddressList.Count);
            List <int> list2 = new List <int>(proxyAddressList.Count);

            lock (this.dictionaryLock)
            {
                int num = 0;
                foreach (ProxyAddress proxyAddress in proxyAddressList)
                {
                    Result <TEntry> item = new Result <TEntry>(default(TEntry), null);
                    if (null == proxyAddress || this.dictionary.TryGetValue(proxyAddress, out item))
                    {
                        list.Add(item);
                    }
                    else
                    {
                        list.Add(item);
                        proxies.Add(proxyAddress);
                        list2.Add(num);
                    }
                    num++;
                }
            }
            if (ADRecipientCache <TEntry> .PerfCounters != null)
            {
                ADRecipientCache <TEntry> .PerfCounters.AggregateHits_Base.Increment();

                if (list2.Count == 0)
                {
                    ADRecipientCache <TEntry> .PerfCounters.AggregateHits.Increment();
                }
                else
                {
                    int num2 = list2.Count / ADRecipientCache <TEntry> .BatchSize;
                    if (list2.Count % ADRecipientCache <TEntry> .BatchSize != 0)
                    {
                        num2++;
                    }
                    ADRecipientCache <TEntry> .PerfCounters.AggregateMisses.IncrementBy((long)num2);
                }
            }
            if (proxies.Count == 0)
            {
                return(list);
            }
            if (ADRecipientCache <TEntry> .PerfCounters != null)
            {
                ADRecipientCache <TEntry> .PerfCounters.BatchedAddressLookupsTotal.Increment();

                ADRecipientCache <TEntry> .PerfCounters.RequestsPendingTotal.Increment();

                ADRecipientCache <TEntry> .PerfCounters.AggregateLookupsTotal.Increment();

                this.IncrementQueriesPerCacheCounter();
            }
            Result <TEntry>[] rawResults = null;
            Stopwatch         stopwatch  = Stopwatch.StartNew();

            try
            {
                int i;
                ADNotificationAdapter.RunADOperation(delegate()
                {
                    if (typeof(TEntry) == typeof(ADRawEntry))
                    {
                        Result <ADRawEntry>[] source = this.ADSession.FindByProxyAddresses(proxies.ToArray(), this.properties);
                        rawResults = (from i in source
                                      select new Result <TEntry>((TEntry)((object)i.Data), i.Error)).ToArray <Result <TEntry> >();
                        return;
                    }
                    if (typeof(TEntry) == typeof(TransportMiniRecipient))
                    {
                        Result <TransportMiniRecipient>[] source2 = this.ADSession.FindByProxyAddresses <TransportMiniRecipient>(proxies.ToArray());
                        rawResults = (from i in source2
                                      select new Result <TEntry>(i.Data as TEntry, i.Error)).ToArray <Result <TEntry> >();
                        return;
                    }
                    throw new NotSupportedException();
                });
            }
            finally
            {
                stopwatch.Stop();
                if (ADRecipientCache <TEntry> .PerfCounters != null)
                {
                    ADRecipientCache <TEntry> .PerfCounters.AverageLookupQueryLatency.IncrementBy(stopwatch.ElapsedMilliseconds);
                }
                ADRecipientCache <TEntry> .DecrementPendingRequestsCounter();
            }
            for (int i = 0; i < rawResults.Length; i++)
            {
                if (rawResults[i].Data != null)
                {
                    this.PopulateCalculatedProperties(rawResults[i].Data);
                }
                list[list2[i]] = rawResults[i];
            }
            bool flag2 = false;

            lock (this.dictionaryLock)
            {
                for (int j = 0; j < proxies.Count; j++)
                {
                    Result <TEntry> value;
                    if (proxies[j] != null && this.dictionary.TryGetValue(proxies[j], out value))
                    {
                        list[list2[j]] = value;
                        flag2          = true;
                    }
                    else
                    {
                        this.AddCacheEntry(proxies[j], list[list2[j]], false, false);
                    }
                }
            }
            if (flag2 && ADRecipientCache <TEntry> .PerfCounters != null)
            {
                ADRecipientCache <TEntry> .PerfCounters.RepeatedQueryForTheSameRecipient.Increment();
            }
            return(list);
        }
        // Token: 0x06001A76 RID: 6774 RVA: 0x0006E40C File Offset: 0x0006C60C
        public virtual Result <TEntry> FindAndCacheRecipient(ADObjectId objectId)
        {
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            if (ADRecipientCache <TEntry> .PerfCounters != null)
            {
                ADRecipientCache <TEntry> .PerfCounters.IndividualAddressLookupsTotal.Increment();

                ADRecipientCache <TEntry> .PerfCounters.RequestsPendingTotal.Increment();

                ADRecipientCache <TEntry> .PerfCounters.AggregateHits_Base.Increment();

                ADRecipientCache <TEntry> .PerfCounters.AggregateMisses.Increment();

                ADRecipientCache <TEntry> .PerfCounters.AggregateLookupsTotal.Increment();

                this.IncrementQueriesPerCacheCounter();
            }
            Stopwatch       stopwatch = Stopwatch.StartNew();
            Result <TEntry> result;

            try
            {
                TEntry entry = default(TEntry);
                ADNotificationAdapter.RunADOperation(delegate()
                {
                    if (typeof(TEntry) == typeof(TransportMiniRecipient))
                    {
                        entry = (this.ADSession.ReadMiniRecipient <TransportMiniRecipient>(objectId, this.properties) as TEntry);
                        return;
                    }
                    if (this.isFullADRecipientObject)
                    {
                        entry = (TEntry)((object)this.ADSession.Read(objectId));
                        return;
                    }
                    entry = (TEntry)((object)this.ADSession.ReadADRawEntry(objectId, this.properties));
                });
                if (entry == null)
                {
                    result = new Result <TEntry>(default(TEntry), ProviderError.NotFound);
                }
                else
                {
                    result = new Result <TEntry>(entry, null);
                }
            }
            catch (DataValidationException ex)
            {
                ComponentTrace <ADRecipientCacheTags> .TraceError <DataValidationException>(0, -1L, "DataValidationException: {0}", ex);

                result = new Result <TEntry>(default(TEntry), ex.Error);
            }
            finally
            {
                stopwatch.Stop();
                if (ADRecipientCache <TEntry> .PerfCounters != null)
                {
                    ADRecipientCache <TEntry> .PerfCounters.AverageLookupQueryLatency.IncrementBy(stopwatch.ElapsedMilliseconds);
                }
                ADRecipientCache <TEntry> .DecrementPendingRequestsCounter();
            }
            if (result.Data != null)
            {
                ProxyAddress primarySmtpAddress = ADRecipientCache <TEntry> .GetPrimarySmtpAddress(result.Data);

                if (primarySmtpAddress != null)
                {
                    this.AddCacheEntry(primarySmtpAddress, result);
                }
            }
            return(result);
        }