Beispiel #1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                string[] v = ((string)value).Split('|');
                if (v.Length != 8)
                {
                    return(null);
                }
                FileName fileName                 = FileName.Create(v[1]);
                int      lineNumber               = int.Parse(v[2], culture);
                int      columnNumber             = int.Parse(v[3], culture);
                Debugging.BreakpointAction action = Debugging.BreakpointAction.Break;
                string scriptLanguage             = "";
                string script = "";
                if (v[0] == "Breakpoint")
                {
                    action         = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
                    scriptLanguage = v[6];
                    script         = v[7];
                }
                if (lineNumber < 0)
                {
                    return(null);
                }
                if (columnNumber < 0)
                {
                    return(null);
                }
                SDBookmark bookmark;
                switch (v[0])
                {
                case "Breakpoint":
                    var bbm = new Debugging.BreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script);
                    bbm.IsEnabled = bool.Parse(v[4]);
                    bookmark      = bbm;
                    break;

                default:
                    bookmark = new SDBookmark(fileName, new Location(columnNumber, lineNumber));
                    break;
                }
                return(bookmark);
            }
            else
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }
Beispiel #2
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                string[] v = ((string)value).Split('|');

                FileName fileName     = FileName.Create(v[1]);
                int      lineNumber   = int.Parse(v[2], culture);
                int      columnNumber = int.Parse(v[3], culture);
                if (lineNumber < 0)
                {
                    return(null);
                }
                if (columnNumber < 0)
                {
                    return(null);
                }
                SDBookmark bookmark;
                switch (v[0])
                {
                case "Breakpoint":
                    Debugging.BreakpointAction action = Debugging.BreakpointAction.Break;
                    string scriptLanguage             = "";
                    string script = "";
                    action         = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
                    scriptLanguage = v[6];
                    script         = v[7];

                    var bbm = new Debugging.BreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script);
                    bbm.IsEnabled      = bool.Parse(v[4]);
                    bbm.Action         = action;
                    bbm.ScriptLanguage = scriptLanguage;
                    bbm.Condition      = script;
                    bookmark           = bbm;
                    break;

                case "DecompiledBreakpointBookmark":
                    action         = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
                    scriptLanguage = v[6];
                    script         = v[7];

                    bbm                = new DecompiledBreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script);
                    bbm.IsEnabled      = bool.Parse(v[4]);
                    bbm.Action         = action;
                    bbm.ScriptLanguage = scriptLanguage;
                    bbm.Condition      = script;
                    bookmark           = bbm;
                    break;

                case "PinBookmark":
                    var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber));
                    pin.Comment     = v[4];
                    pin.PinPosition =
                        new Point
                    {
                        X = double.Parse(v[5], culture),
                        Y = double.Parse(v[6], culture)
                    };

                    // pop-up nodes
                    pin.SavedNodes = new System.Collections.Generic.List <Tuple <string, string, string> >();
                    for (int i = 7; i < v.Length; i += 3)
                    {
                        pin.SavedNodes.Add(new Tuple <string, string, string>(v[i], v[i + 1], v[i + 2]));
                    }

                    bookmark = pin;
                    break;

                default:
                    bookmark = new Bookmark(fileName, new Location(columnNumber, lineNumber));
                    break;
                }
                return(bookmark);
            }
            else
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }