private static ServiceModelPerformanceCountersEntry GetServiceModelPerformanceCountersBaseUri(string uri) { ServiceModelPerformanceCountersEntry entry = null; if (!string.IsNullOrEmpty(uri)) { PerformanceCountersForBaseUri.TryGetValue(uri, out entry); } return(entry); }
internal static void AddPerformanceCountersForEndpoint(ServiceHostBase serviceHost, ContractDescription contractDescription, EndpointDispatcher endpointDispatcher) { if ((PerformanceCountersEnabled || MinimalPerformanceCountersEnabled) && endpointDispatcher.SetPerfCounterId()) { ServiceModelPerformanceCounters counters; lock (perfCounterDictionarySyncObject) { if (!PerformanceCountersForEndpoint.TryGetValue(endpointDispatcher.PerfCounterId, out counters)) { counters = new ServiceModelPerformanceCounters(serviceHost, contractDescription, endpointDispatcher); if (!counters.Initialized) { return; } PerformanceCountersForEndpoint.Add(endpointDispatcher.PerfCounterId, counters); int num = PerformanceCountersForEndpointList.FindIndex(c => c == null); if (num >= 0) { PerformanceCountersForEndpointList[num] = counters; } else { PerformanceCountersForEndpointList.Add(counters); num = PerformanceCountersForEndpointList.Count - 1; } endpointDispatcher.PerfCounterInstanceId = num; } } lock (perfCounterDictionarySyncObject) { ServiceModelPerformanceCountersEntry entry; if (!PerformanceCountersForBaseUri.TryGetValue(endpointDispatcher.PerfCounterBaseId, out entry)) { if (PerformanceCountersEnabled) { entry = new ServiceModelPerformanceCountersEntry(serviceHost.Counters); } else if (MinimalPerformanceCountersEnabled) { entry = new ServiceModelPerformanceCountersEntry(serviceHost.DefaultCounters); } PerformanceCountersForBaseUri.Add(endpointDispatcher.PerfCounterBaseId, entry); } entry.Add(counters); } } }