internal static IActivityScope GetActivityScope(Guid key) { IActivityScope activityScope = null; ActivityScopeImpl activityScopeImpl = null; try { ActivityScopeImpl.scopeCacheLock.EnterReadLock(); if (ActivityScopeImpl.scopeCache.TryGetValue(key, out activityScopeImpl)) { activityScope = activityScopeImpl; } } finally { try { ActivityScopeImpl.scopeCacheLock.ExitReadLock(); } catch (SynchronizationLockException) { } } if (activityScope != null) { return(activityScope); } return(null); }
internal static ActivityScope AddActivityScope(ActivityContextState activityContextState) { Guid guid = Guid.NewGuid(); ActivityScope result; using (DisposeGuard disposeGuard = default(DisposeGuard)) { try { ActivityScopeImpl.scopeCacheLock.EnterWriteLock(); ActivityScopeImpl activityScopeImpl = new ActivityScopeImpl(guid); disposeGuard.Add <ActivityScopeImpl>(activityScopeImpl); ActivityScopeImpl.scopeCache.Add(guid, activityScopeImpl); ActivityScope activityScope = new ActivityScope(activityScopeImpl); disposeGuard.Add <ActivityScope>(activityScope); activityScopeImpl.UpdateFromState(activityContextState); SingleContext.Singleton.LocalId = new Guid?(guid); SingleContext.Singleton.SetId(); disposeGuard.Success(); result = activityScope; } finally { try { ActivityScopeImpl.scopeCacheLock.ExitWriteLock(); } catch (SynchronizationLockException) { } } } return(result); }
private static void LogReport() { Process currentProcess = Process.GetCurrentProcess(); string processName = currentProcess.ProcessName; if (ActivityCoverageReport.statistics.Count > 0) { ActivityCoverageReport.TryLogActivityRollupReportWithUsageEvent(new object[] { processName, ActivityCoverageReport.CachedAppName, ActivityCoverageReport.rollupTime, LogRowFormatter.FormatCollection(ActivityScopeImpl.GetFormattableStatistics(ActivityCoverageReport.statistics)) }); return; } ActivityCoverageReport.TryLogActivityRollupReportWithNoUsageEvent(new object[] { processName, ActivityCoverageReport.CachedAppName, ActivityCoverageReport.rollupTime }); }
public List <KeyValuePair <string, object> > GetFormattableStatistics() { return(ActivityScopeImpl.GetFormattableStatistics(this.statistics)); }