private void button3_Click(object sender, EventArgs e) { Encoder encoder = new Encoder(); encoder.Indent = true; Test o = new Test(); string s = encoder.Encode(o); Decoder decoder = new Decoder(); Test o2 = (Test)decoder.Decode(s); string s2 = encoder.Encode(o2); if (s == s2) richTextBox1.AppendText("OK\n"); else richTextBox1.AppendText("FAIL\n"); }
private void button2_Click(object sender, EventArgs e) { Decoder decoder = new Decoder(); string s = richTextBox1.Text; try { Test o = (Test) decoder.Decode(s); richTextBox1.AppendText("\n" + "ok"); } catch (Exception exc) { richTextBox1.AppendText("\n" + exc.ToString()); } }
private void button3_Click(object sender, EventArgs e) { Encoder encoder = new Encoder(); encoder.Indent = true; Test o = new Test(); string s = encoder.Encode(o); Decoder decoder = new Decoder(); Test o2 = (Test)decoder.Decode(s); string s2 = encoder.Encode(o2); if (s == s2) { richTextBox1.AppendText("OK\n"); } else { richTextBox1.AppendText("FAIL\n"); } }
public static object Decode(string value) { Decoder c = new Decoder(); return(c.Decode(value)); }
public void LoadProject(string filename, bool noPlugins) { try { _projectFilename = filename; _project.Filenames.Clear(); _model.Clear(); _lookup.Clear(); _watcher.Clear(); _rootItem.Files.Clear(); if (!File.Exists(filename)) { _windowManager.Logger.LogStr("Project file was not found:" + filename); return; } // Load the project file. string s = File.ReadAllText(_projectFilename); Hwd.Serialization.Decoder decoder = new Hwd.Serialization.Decoder(); _project = (ProjectDefinition)decoder.Decode(s); if (_project == null) { _windowManager.Logger.LogStr("Failed to deserialize project file:" + _projectFilename); _project = new ProjectDefinition(); return; } // Check the filename list. List <string> remove = new List <string>(); foreach (string name in _project.Filenames) { if (!File.Exists(name)) { remove.Add(name); } else { MatchFileToModel(name); } } foreach (string name in remove) { _project.Filenames.Remove(name); _windowManager.Logger.LogStr("Warning : Project contains a file that was not found:" + name); } // Load item structure in advance, so we can "goto" items. foreach (KeyValuePair <string, BaseItem> pair in _model.Files) { ReadItem(pair.Value, false); _watcher.AddWatch(pair.Value); } // This must be done before we set current item in the tree. RefreshModel(); SetCaption(); // Load favourites, global ignores, and plugin options as part of the project. _windowManager.Favourites.AddAll(_project.Favourites); _windowManager.SetCaption(_projectFilename); // Load settings for windows. if (!noPlugins) { _windowManager.SetWindowItems(_project.Windows, _project.Items); } // Load the project item. We avoid selecting it here because each // window will load it's own current item anyway, above. BaseItem item = Lookup(_project.ProjectItem); try { _ignoreSelect = true; SetActiveItem(item, this); } finally { _ignoreSelect = false; } // Notify files changed. if (!noPlugins) { if (OnFilesChanged != null) { OnFilesChanged(_rootItem, new EventArgs()); } } _watcher.Start(); } catch (SerializationException exc) { _windowManager.Logger.LogExcStr(exc, "Deserializing project failed"); } catch (IOException exc) { _windowManager.Logger.LogExcStr(exc, "Load project failed"); } }
public static object Decode(string value) { Decoder c = new Decoder(); return c.Decode(value); }
public void LoadProject(string filename, bool noPlugins) { try { _projectFilename = filename; _project.Filenames.Clear(); _model.Clear(); _lookup.Clear(); _watcher.Clear(); _rootItem.Files.Clear(); if (!File.Exists(filename)) { _windowManager.Logger.LogStr("Project file was not found:" + filename); return; } // Load the project file. string s = File.ReadAllText(_projectFilename); Hwd.Serialization.Decoder decoder = new Hwd.Serialization.Decoder(); _project = (ProjectDefinition)decoder.Decode(s); if (_project == null) { _windowManager.Logger.LogStr("Failed to deserialize project file:" + _projectFilename); _project = new ProjectDefinition(); return; } // Check the filename list. List<string> remove = new List<string>(); foreach (string name in _project.Filenames) { if (!File.Exists(name)) { remove.Add(name); } else { MatchFileToModel(name); } } foreach (string name in remove) { _project.Filenames.Remove(name); _windowManager.Logger.LogStr("Warning : Project contains a file that was not found:" + name); } // Load item structure in advance, so we can "goto" items. foreach (KeyValuePair<string, BaseItem> pair in _model.Files) { ReadItem(pair.Value, false); _watcher.AddWatch(pair.Value); } // This must be done before we set current item in the tree. RefreshModel(); SetCaption(); // Load favourites, global ignores, and plugin options as part of the project. _windowManager.Favourites.AddAll(_project.Favourites); _windowManager.SetCaption(_projectFilename); // Load settings for windows. if (!noPlugins) _windowManager.SetWindowItems(_project.Windows, _project.Items); // Load the project item. We avoid selecting it here because each // window will load it's own current item anyway, above. BaseItem item = Lookup(_project.ProjectItem); try { _ignoreSelect = true; SetActiveItem(item, this); } finally { _ignoreSelect = false; } // Notify files changed. if (!noPlugins) if (OnFilesChanged != null) OnFilesChanged(_rootItem, new EventArgs()); _watcher.Start(); } catch (SerializationException exc) { _windowManager.Logger.LogExcStr(exc, "Deserializing project failed"); } catch (IOException exc) { _windowManager.Logger.LogExcStr(exc, "Load project failed"); } }