public AddDirectoryCacheRequest(List <Tuple <string, KeyType> > keys, ADRawEntry objectToCache, string forestFqdn, OrganizationId organizationId, IEnumerable <PropertyDefinition> properties, int secondsTimeout = 2147483646, CacheItemPriority priority = CacheItemPriority.Default) { ArgumentValidator.ThrowIfNull("keys", keys); ArgumentValidator.ThrowIfNull("objectToCache", objectToCache); ArgumentValidator.ThrowIfOutOfRange <int>("secondsTimeout", secondsTimeout, 1, 2147483646); ArgumentValidator.ThrowIfNull("organizationId", organizationId); if (keys.Count == 0) { throw new InvalidOperationException("Keys should not be empty"); } this.Keys = keys; ADObject adobject = objectToCache as ADObject; if (adobject != null) { this.Object = SimpleADObject.CreateFrom(adobject, properties); } else { this.Object = SimpleADObject.CreateFromRawEntry(objectToCache, properties, true); } this.ObjectType = CacheUtils.GetObjectTypeFor(objectToCache.GetType(), true); this.SecondsTimeout = secondsTimeout; this.Priority = priority; base.ForestOrPartitionFqdn = forestFqdn; base.InternalSetOrganizationId(organizationId); }
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); }