public void SelectAllMethodDefinitions() { if (lstBoxAnalyze.SelectedItems.Count > 0) { lstBoxAnalyze.UnselectAll(); } else { int i = 0; while (i < lstBoxAnalyze.Items.Count) { ListBoxItem lbi = (ListBoxItem)lstBoxAnalyze.ItemContainerGenerator.ContainerFromIndex(i); aPart a = lstBoxAnalyze.Items[i] as aPart; if (a.Editible) { lstBoxAnalyze.SelectedItems.Add(lstBoxAnalyze.Items.GetItemAt(i)); } i++; } } }
private string analyze(string assemblyPath, bool WithTrace = false) { AssemblyDefinition asmDef; string fileName = Path.GetFileName(assemblyPath); StringBuilder ReturnString = new StringBuilder(); string s = String.Empty; // Load assembly asmDef = AssemblyDefinition.ReadAssembly(assemblyPath); foreach (ModuleDefinition modDef in asmDef.Modules) { s = modDef.Name + " (" + modDef.MetadataToken.RID + ")" + NewLine; ReturnString.Append(s); if (WithTrace) { Trace.WriteLine(s); } aPart a = new aPart(); a.Name = s; a.Token = modDef.MetadataToken.ToString(); a.Type = aPart.Types.ModuleDefinition; a.Editible = false; // Icon GenerateImage("MoImage"); a.Image = _tempImage; aParts.Add(a); foreach (TypeDefinition typDef in modDef.Types) { s = " " + typDef.Name + " (" + typDef.MetadataToken.RID + ")" + NewLine; ReturnString.Append(s); if (WithTrace) { Trace.WriteLine(s); } a = new aPart(); a.Name = s; a.Token = typDef.MetadataToken.ToString(); a.Type = aPart.Types.TypeDefinition; a.Editible = false; // Icon GenerateImage("TyImage"); a.Image = _tempImage; aParts.Add(a); foreach (MethodDefinition metDef in typDef.Methods) { s = " " + metDef.Name + " (" + metDef.MetadataToken.RID + ")" + NewLine; ReturnString.Append(s); if (WithTrace) { Trace.WriteLine(s); } a = new aPart(); a.Name = s; a.Token = metDef.MetadataToken.ToString(); a.Type = aPart.Types.MethodDefinition; a.Editible = true; // Icon GenerateImage("MeImage"); a.Image = _tempImage; aParts.Add(a); if (metDef.Parameters != null && metDef.Parameters.Count > 0) { foreach (ParameterDefinition param in metDef.Parameters) { s = " Type: " + param.ParameterType.ToString() + " Name: " + param.Name + NewLine; s += " Attributes: " + param.Attributes.ToString(); ReturnString.Append(s); if (WithTrace) { Trace.WriteLine(s); } a = new aPart(); a.Name = s; a.Token = param.MetadataToken.ToString(); a.Type = aPart.Types.ParameterDefinition; a.Editible = false; // Icon GenerateImage("PaImage"); a.Image = _tempImage; aParts.Add(a); } } if (metDef.Body != null && metDef.Body.Variables != null && metDef.Body.Variables.Count > 0) { foreach (VariableDefinition variable in metDef.Body.Variables) { s = " Type: " + variable.VariableType.ToString() + " Name: " + variable.Name + NewLine; s += " Index: " + variable.Index.ToString(); ReturnString.Append(s); if (WithTrace) { Trace.WriteLine(s); } a = new aPart(); a.Name = s; a.Type = aPart.Types.VariableDefinition; a.Editible = false; // Icon GenerateImage("PaImage"); a.Image = _tempImage; aParts.Add(a); } } } } } TextView = ReturnString.ToString(); View = new MyToolkit.Collections.ObservableCollectionView <aPart>(aParts); UpdateFilter(); return(ReturnString.ToString()); }