public void Put(AddDirectoryCacheRequest cacheRequest)
        {
            ArgumentValidator.ThrowIfNull("cacheRequest", cacheRequest);
            int       retryCount = 0;
            long      apiTime    = 0L;
            Stopwatch stopwatch  = Stopwatch.StartNew();

            ExchangeDirectoryCacheProvider.proxyPool.CallServiceWithRetry(delegate(IPooledServiceProxy <IDirectoryCacheClient> proxy)
            {
                Stopwatch stopwatch2 = Stopwatch.StartNew();
                try
                {
                    retryCount++;
                    this.IsNewProxyObject = string.IsNullOrEmpty(proxy.Tag);
                    CacheResponseContext cacheResponseContext = proxy.Client.PutObject(cacheRequest);
                    proxy.Tag = DateTime.UtcNow.ToString();
                    CachePerformanceTracker.AddPerfData(Operation.WCFBeginOperation, cacheResponseContext.BeginOperationLatency);
                    CachePerformanceTracker.AddPerfData(Operation.WCFEndOperation, cacheResponseContext.EndOperationLatency);
                }
                finally
                {
                    stopwatch2.Stop();
                    CachePerformanceTracker.AddPerfData(Operation.WCFPutOperation, stopwatch2.ElapsedMilliseconds);
                    apiTime = stopwatch2.ElapsedMilliseconds;
                }
            }, string.Format("Adding {0} object to cache", cacheRequest.ObjectType), 3);
            stopwatch.Stop();
            CachePerformanceTracker.AddPerfData(Operation.WCFProxyObjectCreation, stopwatch.ElapsedMilliseconds - apiTime);
            this.RetryCount = retryCount;
        }
        public TObject Get <TObject>(DirectoryCacheRequest cacheRequest) where TObject : ADRawEntry, new()
        {
            ArgumentValidator.ThrowIfNull("cacheRequest", cacheRequest);
            CacheUtils.PopulateAndCheckObjectType <TObject>(cacheRequest);
            SimpleADObject sADO       = null;
            int            retryCount = 0;
            long           apiTime    = 0L;
            Stopwatch      stopwatch  = Stopwatch.StartNew();

            ExchangeDirectoryCacheProvider.proxyPool.CallServiceWithRetry(delegate(IPooledServiceProxy <IDirectoryCacheClient> proxy)
            {
                Stopwatch stopwatch3 = Stopwatch.StartNew();
                try
                {
                    retryCount++;
                    this.IsNewProxyObject    = string.IsNullOrEmpty(proxy.Tag);
                    GetObjectContext @object = proxy.Client.GetObject(cacheRequest);
                    sADO             = @object.Object;
                    this.ResultState = @object.ResultState;
                    CachePerformanceTracker.AddPerfData(Operation.WCFBeginOperation, @object.BeginOperationLatency);
                    CachePerformanceTracker.AddPerfData(Operation.WCFEndOperation, @object.EndOperationLatency);
                    proxy.Tag = DateTime.UtcNow.ToString();
                }
                finally
                {
                    stopwatch3.Stop();
                    CachePerformanceTracker.AddPerfData(Operation.WCFGetOperation, stopwatch3.ElapsedMilliseconds);
                    apiTime = stopwatch3.ElapsedMilliseconds;
                }
            }, string.Format("Get Object {0}", typeof(TObject).FullName), 3);
            stopwatch.Stop();
            CachePerformanceTracker.AddPerfData(Operation.WCFProxyObjectCreation, stopwatch.ElapsedMilliseconds - apiTime);
            this.RetryCount = retryCount;
            TObject result = default(TObject);

            if (sADO != null)
            {
                Stopwatch stopwatch2 = Stopwatch.StartNew();
                CachePerformanceTracker.AddPerfData(Operation.DataSize, (long)sADO.Data.Length);
                sADO.Initialize(false);
                stopwatch2.Stop();
                CachePerformanceTracker.AddPerfData(Operation.ObjectInitialization, stopwatch2.ElapsedMilliseconds);
                stopwatch2.Restart();
                if (!typeof(TObject).Equals(typeof(ADRawEntry)))
                {
                    result = SimpleADObject.CreateFrom <TObject>(sADO, null, cacheRequest.ADPropertiesRequested);
                }
                else
                {
                    result = (TObject)((object)SimpleADObject.CreateFrom(sADO, cacheRequest.ADPropertiesRequested));
                }
                stopwatch2.Stop();
                CachePerformanceTracker.AddPerfData(Operation.ObjectCreation, stopwatch2.ElapsedMilliseconds);
            }
            return(result);
        }