Beispiel #1
0
        public override void Execute(TVContext context)
        {
            int secretNum = new Random().Next() % 10;

            dnSpy.Shared.App.MsgBox.Instance.Ask <int?>("Number", null, "Guess a number", null, s => {
                int num;
                if (string.IsNullOrWhiteSpace(s))
                {
                    return("Enter a number");
                }
                if (!int.TryParse(s, out num))
                {
                    return("Not an integer");
                }
                if (num == 42)
                {
                    return("Nope!");
                }
                if (num != secretNum)
                {
                    return("WRONG!!!");
                }
                return(string.Empty);
            });
        }
Beispiel #2
0
 IMDTokenNode GetTokenNode(TVContext context)
 {
     if (context.Nodes.Length == 0)
     {
         return(null);
     }
     return(context.Nodes[0] as IMDTokenNode);
 }
Beispiel #3
0
        public override void Execute(TVContext context)
        {
            var instr = GetSecondInstruction(context);

            if (instr != null)
            {
                Clipboard.SetText(string.Format("Second instruction: {0}", instr));
            }
        }
Beispiel #4
0
        public override void Execute(TVContext context)
        {
            var node = GetTokenNode(context);

            if (node != null)
            {
                Clipboard.SetText(string.Format("{0:X8}", node.Reference.MDToken.Raw));
            }
        }
Beispiel #5
0
        public override string GetHeader(TVContext context)
        {
            var node = GetTokenNode(context);

            if (node == null)
            {
                return(string.Empty);
            }
            return(string.Format("Copy token {0:X8}", node.Reference.MDToken.Raw));
        }
Beispiel #6
0
        public override void Execute(TVContext context)
        {
            var instr = GetSecondInstruction(context);

            if (instr != null)
            {
                try {
                    Clipboard.SetText(string.Format("Second instruction: {0}", instr));
                }
                catch (ExternalException) { }
            }
        }
Beispiel #7
0
        public override void Execute(TVContext context)
        {
            var node = GetTokenNode(context);

            if (node != null)
            {
                try {
                    Clipboard.SetText(string.Format("{0:X8}", node.Reference.MDToken.Raw));
                }
                catch (ExternalException) { }
            }
        }
Beispiel #8
0
        Instruction GetSecondInstruction(TVContext context)
        {
            if (context.Nodes.Length == 0)
            {
                return(null);
            }
            var methNode = context.Nodes[0] as IMethodNode;

            if (methNode == null)
            {
                return(null);
            }
            var body = methNode.MethodDef.Body;

            if (body == null || body.Instructions.Count < 2)
            {
                return(null);
            }
            return(body.Instructions[1]);
        }
Beispiel #9
0
 public override bool IsVisible(TVContext context)
 {
     return(context.Nodes.Length > 0);
 }
Beispiel #10
0
 public override void Execute(TVContext context)
 {
     dnSpy.Shared.App.MsgBox.Instance.Show("Command #2");
 }
Beispiel #11
0
 public override bool IsEnabled(TVContext context)
 {
     return(context.Nodes.Length > 1);
 }
Beispiel #12
0
 public override bool IsEnabled(TVContext context)
 {
     return(GetSecondInstruction(context) != null);
 }
Beispiel #13
0
 public override bool IsVisible(TVContext context)
 {
     return(GetTokenNode(context) != null);
 }
Beispiel #14
0
 public override bool IsEnabled(TVContext context)
 {
     return(context.Nodes.Length == 1 &&
            context.Nodes[0] is IModuleFileNode);
 }