internal static void RegisterDiagnosticsComponents() { ExchangeDiagnosticsSection config = ExchangeDiagnosticsSection.GetConfig(); ExTraceGlobals.CommonTracer.TraceInformation <int>(0, 0L, "ExchangeDiagnosticsHelper::RegisterDiagnosticsComponents called. No of Component:{0}", config.DiagnosticComponents.Count); foreach (object obj in config.DiagnosticComponents) { DiagnosticsComponent diagnosticsComponent = (DiagnosticsComponent)obj; ExTraceGlobals.CommonTracer.TraceDebug(0L, "ExchangeDiagnosticsHelper::RegisterDiagnosticsComponents ComponentName:{0}, Type:{1}, MethodName:{2}, Argument:{3}", new object[] { diagnosticsComponent.Name, diagnosticsComponent.Implementation, diagnosticsComponent.MethodName, diagnosticsComponent.Argument }); IDiagnosable instance = ExchangeDiagnosticsHelper.GetInstance(diagnosticsComponent); if (diagnosticsComponent.Data != null) { IDiagnosableExtraData diagnosableExtraData = instance as IDiagnosableExtraData; if (diagnosableExtraData != null) { diagnosableExtraData.SetData(diagnosticsComponent.Data); } } ExchangeDiagnosticsHelper.RegisterDiagnosticsComponents(instance); } }
private static IDiagnosable GetInstance(DiagnosticsComponent component) { Type type = Type.GetType(component.Implementation, false); IDiagnosable result = null; if (type != null) { MethodInfo method = type.GetMethod(component.MethodName, BindingFlags.Static | BindingFlags.Public); if (!string.IsNullOrEmpty(component.Argument)) { result = (method.Invoke(null, new object[] { component.Argument }) as IDiagnosable); } else { result = (method.Invoke(null, null) as IDiagnosable); } ExTraceGlobals.CommonTracer.TraceDebug <string>(0L, "ExchangeDiagnosticsHelper::GetInstance - instance of {0} created successfully", component.Implementation); } else { ExTraceGlobals.CommonTracer.TraceDebug <string>(0L, "ExchangeDiagnosticsHelper::GetInstance - could not find {0}", component.Implementation); } return(result); }