private IEnumerable <InteractiveDiagnosticMethod> GetDiagnosticMethods(IDiagnosticsProvider diagnosticsProvider) { var objectMethods = typeof(object).GetMethods().Select(x => x.Name).ToList(); var methods = diagnosticsProvider.DiagnosticObject .GetType() .GetMethods(Flags) .Where(x => !objectMethods.Contains(x.Name)) .Where(mi => !mi.IsSpecialName) .ToArray(); var diagnosticMethods = new List <InteractiveDiagnosticMethod>(methods.Length); foreach (var methodInfo in methods) { diagnosticMethods.Add(new InteractiveDiagnosticMethod( diagnosticsProvider.DiagnosticObject, methodInfo.ReturnType, methodInfo.Name, this.GetArguments(methodInfo), this.GetDescription(diagnosticsProvider, methodInfo))); } return(diagnosticMethods); }
private static string GetDescriptionFromProperty(IDiagnosticsProvider diagnosticsProvider, MethodInfo methodInfo) { var propertyName = String.Format("{0}{1}", methodInfo.Name, "Description"); var property = diagnosticsProvider.DiagnosticObject.GetType().GetProperty(propertyName); if (property == null) { return(null); } return((string)property.GetValue(diagnosticsProvider.DiagnosticObject, null)); }
private static string GetDescriptionFromProperty(IDiagnosticsProvider diagnosticsProvider, MethodInfo methodInfo) { var propertyName = String.Format("{0}{1}", methodInfo.Name, "Description"); var property = diagnosticsProvider.DiagnosticObject.GetType().GetProperty(propertyName); if (property == null) { return null; } return (string)property.GetValue(diagnosticsProvider.DiagnosticObject, null); }
public void Should_return_methods_from_entire_hierarchy() { //Given var child = new FakeChildDiagnosticsProvider(); var parent = new FakeParentDiagnosticsProvider(); IEnumerable <IDiagnosticsProvider> ie = new IDiagnosticsProvider[] { child, parent }; var id = new InteractiveDiagnostics(ie); var ad = id.AvailableDiagnostics; //When int methodsInParent = ad.ElementAt(1).Methods.Count(); int methodsInChild = ad.First().Methods.Count(); //Then Assert.True(methodsInChild == methodsInParent + 1); }
public void Should_return_methods_from_entire_hierarchy() { //Given var child = new FakeChildDiagnosticsProvider(); var parent = new FakeParentDiagnosticsProvider(); IEnumerable<IDiagnosticsProvider> ie = new IDiagnosticsProvider[] { child, parent }; var id = new InteractiveDiagnostics(ie); var ad = id.AvailableDiagnostics; //When int methodsInParent = ad.ElementAt(1).Methods.Count(); int methodsInChild = ad.First().Methods.Count(); //Then Assert.True(methodsInChild == methodsInParent + 1); }
private static string GetDescriptionFromAttribute(IDiagnosticsProvider diagnosticsProvider, MethodInfo methodInfo) { var attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(methodInfo, typeof(DescriptionAttribute)); return(attribute != null ? attribute.Description : null); }
private string GetDescription(IDiagnosticsProvider diagnosticsProvider, MethodInfo methodInfo) { return(GetDescriptionFromProperty(diagnosticsProvider, methodInfo) ?? GetDescriptionFromAttribute(diagnosticsProvider, methodInfo)); }
private static string GetDescriptionFromAttribute(IDiagnosticsProvider diagnosticsProvider, MethodInfo methodInfo) { var attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(methodInfo, typeof(DescriptionAttribute)); return attribute != null ? attribute.Description : null; }
private IEnumerable<InteractiveDiagnosticMethod> GetDiagnosticMethods(IDiagnosticsProvider diagnosticsProvider) { var objectMethods = typeof(object).GetMethods().Select(x => x.Name).ToList(); var methods = diagnosticsProvider.DiagnosticObject .GetType() .GetMethods(Flags) .Where(x => !objectMethods.Contains(x.Name)) .Where(mi => !mi.IsSpecialName) .ToArray(); var diagnosticMethods = new List<InteractiveDiagnosticMethod>(methods.Length); foreach (var methodInfo in methods) { diagnosticMethods.Add(new InteractiveDiagnosticMethod( diagnosticsProvider.DiagnosticObject, methodInfo.ReturnType, methodInfo.Name, this.GetArguments(methodInfo), this.GetDescription(diagnosticsProvider, methodInfo))); } return diagnosticMethods; }
private string GetDescription(IDiagnosticsProvider diagnosticsProvider, MethodInfo methodInfo) { return GetDescriptionFromProperty(diagnosticsProvider, methodInfo) ?? GetDescriptionFromAttribute(diagnosticsProvider, methodInfo); }
private IEnumerable<InteractiveDiagnosticMethod> GetDiagnosticMethods(IDiagnosticsProvider diagnosticsProvider) { var methods = diagnosticsProvider.DiagnosticObject.GetType().GetMethods(Flags); var diagnosticMethods = new List<InteractiveDiagnosticMethod>(methods.Length); foreach (var methodInfo in methods) { diagnosticMethods.Add(new InteractiveDiagnosticMethod( diagnosticsProvider.DiagnosticObject, methodInfo.ReturnType, methodInfo.Name, this.GetArguments(methodInfo), this.GetDescription(diagnosticsProvider, methodInfo))); } return diagnosticMethods; }
public DiagnosticsProviderDecorator(IDiagnosticsProvider diagnosticsProvider) : base(diagnosticsProvider.Name) { mDiagnosticsProvider = diagnosticsProvider; mUnhealthyResult = Task.FromResult(HealthCheckResult.Unhealthy($"Health check failed for {mDiagnosticsProvider.Name}")); }