internal static void Set(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex, long value) { PerformanceCounter counter = null; try { if (counters != null) { counter = counters[counterIndex]; if (counter != null) { counter.RawValue = value; } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]); counters[counterIndex] = null; PerformanceCounters.ReleasePerformanceCounter(ref counter); } }
internal static string CreateFriendlyInstanceName(string service, string contract, string uri) { int totalLen = ((service.Length + contract.Length) + uri.Length) + 2; if (totalLen > 0x40) { int num2 = 0; truncOptions options = GetCompressionTasks(totalLen, service.Length, contract.Length, uri.Length); if ((options & (truncOptions.NoBits | truncOptions.service15)) > truncOptions.NoBits) { num2 = 15; service = PerformanceCountersBase.GetHashedString(service, num2 - 2, (service.Length - num2) + 2, true); } if ((options & truncOptions.contract16) > truncOptions.NoBits) { num2 = 0x10; contract = PerformanceCountersBase.GetHashedString(contract, num2 - 2, (contract.Length - num2) + 2, true); } if ((options & (truncOptions.NoBits | truncOptions.uri31)) > truncOptions.NoBits) { num2 = 0x1f; uri = PerformanceCountersBase.GetHashedString(uri, 0, (uri.Length - num2) + 2, false); } } return(service + "." + contract + "@" + uri.Replace('/', '|')); }
static internal void Set(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex, long value) { PerformanceCounter counter = null; try { if (counters != null) { counter = counters[counterIndex]; if (counter != null) { counter.RawValue = value; } } } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]); counters[counterIndex] = null; PerformanceCounters.ReleasePerformanceCounter(ref counter); } }
internal static string CreateFriendlyInstanceName(ServiceHostBase serviceHost) { string firstAddress; ServiceInfo info = new ServiceInfo(serviceHost); string serviceName = info.ServiceName; if (!TryGetFullVirtualPath(serviceHost, out firstAddress)) { firstAddress = info.FirstAddress; } int totalLen = (serviceName.Length + firstAddress.Length) + 2; if (totalLen > 0x40) { int num2 = 0; truncOptions options = GetCompressionTasks(totalLen, serviceName.Length, firstAddress.Length); if ((options & (truncOptions.NoBits | truncOptions.service32)) > truncOptions.NoBits) { num2 = 0x20; serviceName = PerformanceCountersBase.GetHashedString(serviceName, num2 - 2, (serviceName.Length - num2) + 2, true); } if ((options & (truncOptions.NoBits | truncOptions.uri31)) > truncOptions.NoBits) { num2 = 0x1f; firstAddress = PerformanceCountersBase.GetHashedString(firstAddress, 0, (firstAddress.Length - num2) + 2, false); } } return(serviceName + "@" + firstAddress.Replace('/', '|')); }