/// <summary> /// Makes a new item. /// </summary> /// <param name="exception">The exception.</param> /// <param name="method">The method.</param> /// <param name="group">The group.</param> /// <returns></returns> protected ItemInfo MakeItem(ThrownException exception, Method method = null, ListViewGroup group = null) { bool isMethod = (method != null); bool isProperty = isMethod && method.MethodBase.IsProperty(); bool isThrow = !isMethod && (exception != null); if (!isMethod) { method = exception.Method; } ListViewItem item; PropertyInfo pi = null; if (isProperty) { bool getter = method.MethodBase.Name.StartsWith("get_"); pi = method.MethodBase.GetMethodProperty(); item = new ListViewItem(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", pi.Name, getter ? "get" : "set")); } else { item = new ListViewItem(method.ToString()); } if (isProperty) { item.ImageKey = NodeInfo.ImageKeyFromObject(pi); } else if (isMethod) { // use the method for the icon item.ImageKey = NodeInfo.ImageKeyFromObject(method.MethodBase); } else { // use the exception for the icon item.ImageKey = NodeInfo.ImageKeyFromObject(exception.Exception); } ItemInfo info; MethodItem me = new MethodItem(method, exception); if (exception == null) { info = new ItemInfo(item, me, NodeType.Method); item.SubItems.Add(""); } else { info = new ItemInfo(item, me, NodeType.Method); info.Expandable = !isThrow; item.SubItems.Add(exception.Exception.Name); } item.Tag = info; item.SubItems.Add(method.MethodBase.DeclaringType.Name); item.SubItems.Add(method.MethodBase.DeclaringType.Module.Name); item.IndentCount = 1; if (group != null) { item.Group = group; } return info; }
void ShowMethodCall(Method caller, Method called) { Job.SourceView.NewJob(this.SourceViewer, (cancelToken) => { if ((caller == null) || (caller == called)) { this.SourceViewer.SetSource(called.MethodBase, cancelToken); } else { //this.SourceViewer.SetSource(caller.MethodBase, called.MethodBase, caller.Calls[called]); List<SourceViewer.HighlightItem> items = new List<SourceViewer.HighlightItem>(); foreach (int offset in caller.Calls[called]) { items.Add(new SourceViewer.HighlightItem(called.MethodBase) { Display = Decompiler.SourceViewer.HighlightDisplay.Highlight, Offset = offset, Tooltip = called.ToString() }); } this.SourceViewer.SetSource(caller.MethodBase, items, cancelToken); } }).Execute(); }