Пример #1
0
        public string GetString(out string s)
        {
            string error;

            s = NumberVMUtils.ParseString(text, true, out error);
            return(error);
        }
Пример #2
0
        public override bool SetText(string newText)
        {
            string fullName = FullName;

            Value val = null;

            try {
                val = this.Expression.Evaluate(WindowsDebugger.DebuggedProcess);
                if (val.Type.IsInteger && newText.StartsWith("0x"))
                {
                    try {
                        val.PrimitiveValue = long.Parse(newText.Substring(2), NumberStyles.HexNumber);
                    } catch (FormatException) {
                        throw new NotSupportedException();
                    } catch (OverflowException) {
                        throw new NotSupportedException();
                    }
                }
                else if (val.Type.FullName == typeof(string).FullName)
                {
                    string error;
                    newText = NumberVMUtils.ParseString(newText, false, out error);
                    if (!string.IsNullOrEmpty(error))
                    {
                        MainWindow.Instance.ShowMessageBox(string.Format("The string is not a valid C# string. Error: {0}", error));
                        return(false);
                    }
                    val.PrimitiveValue = newText;
                }
                else
                {
                    val.PrimitiveValue = newText;
                }
                this.Text = newText;
                return(true);
            } catch (NotSupportedException) {
                string format = "Can not convert {0} to {1}";
                string msg    = string.Format(format, newText, val.Type.PrimitiveType);
                MainWindow.Instance.ShowMessageBox(msg);
            } catch (COMException) {
                // COMException (0x80131330): Cannot perfrom SetValue on non-leaf frames.
                // Happens if trying to set value after exception is breaked
                MainWindow.Instance.ShowMessageBox("UnknownError");
            }
            return(false);
        }