public void FixHeight(ResultsInterface visualResults) { double tallest = 0.0; foreach (Control child in visualResults.resultsPanel.Children) { if (child is MethodEntry) { MethodEntry methodChild = (MethodEntry)child; foreach (Border border in methodChild.Children) { if (border.ActualHeight > tallest) { tallest = border.ActualHeight; } } foreach (Border border in methodChild.Children) { border.Height = tallest; } } } }
public void FixWidth(ResultsInterface visualResults) { double widestA = 0.0; double widestB = 0.0; double widestC = 0.0; double widestD = 0.0; foreach (Control child in visualResults.resultsPanel.Children) { if (child is MethodEntry) { MethodEntry methodChild = (MethodEntry)child; if (methodChild.columnA.ActualWidth > widestA) { widestA = methodChild.columnA.ActualWidth; } if (methodChild.columnB.ActualWidth > widestB) { widestB = methodChild.columnB.ActualWidth; } if (methodChild.columnC.ActualWidth > widestC) { widestC = methodChild.columnC.ActualWidth; } if (methodChild.columnD.ActualWidth > widestD) { widestD = methodChild.columnD.ActualWidth; } } } foreach (Control child in visualResults.resultsPanel.Children) { if (child is MethodEntry) { MethodEntry methodChild = (MethodEntry)child; methodChild.columnA.Width = widestA; methodChild.columnB.Width = widestB; methodChild.columnC.Width = widestC; methodChild.columnD.Width = widestD; } } }
/// <summary> /// Displays File Reflection information in a window containing a StackPanel with a MethodEntry control for each reflected method. /// </summary> /// <param name="path">Full pathname of the file to be reflected.</param> public void ReflectFile(string path) { ResultsInterface visualResults = new ResultsInterface(); var assembly = Assembly.LoadFile(path); int classNumber = 1; foreach (var type in assembly.GetTypes()) { ClassHeader header = new ClassHeader(); header.ClassName = type.Name; header.NameSpace = type.Namespace; header.FullName = type.FullName; visualResults.resultsPanel.Children.Add(header); results += classNumber + $". Class: {type.Name}:" + Environment.NewLine; results += $" Namespace: {type.Namespace}" + Environment.NewLine; results += $" Full name: {type.FullName}" + Environment.NewLine; results += $" Methods:" + Environment.NewLine; foreach (var methodInfo in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) { MethodEntry temp = new MethodEntry(); temp.MethodName = methodInfo.Name; if (methodInfo.IsPublic) { temp.MemberInfo = "Public"; } if (methodInfo.IsFamily) { temp.MemberInfo = "Protected"; } if (methodInfo.IsAssembly) { temp.MemberInfo = "Internal"; } if (methodInfo.IsPrivate) { temp.MemberInfo = "Private"; } if (verboseCheck.IsChecked == false) { temp.ReturnType = methodInfo.ReturnType.ToString(); temp.Arguments = string.Join(Environment.NewLine, methodInfo.GetParameters().Select(x => x.ParameterType)); } else { temp.ReturnType = Truncate(methodInfo.ReturnType.ToString()); string arguments = ""; ParameterInfo[] argumentInfo = methodInfo.GetParameters(); foreach (ParameterInfo argument in argumentInfo) { arguments += Truncate(argument.ParameterType.ToString()) + Environment.NewLine; } temp.Arguments = arguments; } //temp.Arguments = string.Join(", ", methodInfo.GetParameters().Select(x => x.ParameterType)); visualResults.resultsPanel.Children.Add(temp); } classNumber++; } visualResults.Show(); FixWidth(visualResults); FixHeight(visualResults); visualResults.UpdateLayout(); }