コード例 #1
0
        private void openValueInLocalsWindowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var member = Tag;

                if (member is FieldInfo)
                {
                    object value = ((FieldInfo)member).GetValue(null);
                    LocalsDebugger.LocalsWindow dlg = new LocalsDebugger.LocalsWindow(((FieldInfo)member).GetName(true), value);
                    dlg.FormClosed += (s, ev) => dlg.Dispose();
                    dlg.Show(this);
                }
                else if (member is PropertyInfo)
                {
                    object value = ((PropertyInfo)member).GetValue(null, null);
                    LocalsDebugger.LocalsWindow dlg = new LocalsDebugger.LocalsWindow(((PropertyInfo)member).GetName(true), value);
                    dlg.FormClosed += (s, ev) => dlg.Dispose();
                    dlg.Show(this);
                }
                else if (member is InstanceFinderManager.InstanceResult)
                {
                    var    result = ((InstanceFinderManager.InstanceResult)member);
                    object value  = result.Instance;
                    LocalsDebugger.LocalsWindow dlg = new LocalsDebugger.LocalsWindow(result.Origin.GetName(true), value);
                    dlg.FormClosed += (s, ev) => dlg.Dispose();
                    dlg.Show(this);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to evaluate member: " + ex.ToExceptionString());
            }
        }
コード例 #2
0
        private void useStaticMemberAsBaseInLocalsWindowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!(Tag is MemberInfo))
            {
                return;
            }

            var member = (MemberInfo)Tag;

            LocalsDebugger.LocalsWindow dlg = new LocalsDebugger.LocalsWindow("", null);
            dlg.Show();
            dlg.FormClosed += (s, ev) => dlg.Dispose();

            if (member is Type)
            {
                dlg.SetInput(member.ToSignatureString());
            }
            else
            {
                string typeName;
                if (member.DeclaringType != null)
                {
                    typeName = AliasManager.Instance.GetAlias(member.DeclaringType);
                    if (string.IsNullOrEmpty(typeName))
                    {
                        typeName = member.DeclaringType.Namespace + "." + member.DeclaringType.Name;
                    }
                }
                else
                {
                    typeName = "";
                }

                string memberName = AliasManager.Instance.GetAlias(member);
                if (string.IsNullOrEmpty(memberName))
                {
                    memberName = member.Name;
                }

                dlg.SetInput((string.IsNullOrEmpty(typeName) ? "" : typeName + ".") + memberName);
            }
        }