public void Load(string path, Enum @enum) { switch (@enum) { case CurrentDocType.Json: { var json = new JsonTranslator(CurrentDocumentType, FutureDocumentType, FilePath); json.Translate(FutureDocumentType); break; } case CurrentDocType.Xml: { var serializer = new XmlSerializer(typeof(root)); StreamReader reader = new StreamReader(FilePath); XmlRoot = (root)serializer.Deserialize(reader); reader.Close(); break; } case CurrentDocType.Html: { var html = new HtmlTranslator(CurrentDocumentType, FutureDocumentType, FilePath); html.Translate(FutureDocumentType); break; } } }
private void ListBoxItem_ViewCurrentDocumentType_OnSelected(object p_sender, RoutedEventArgs p_e) { FilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Components\DefaultLisaResume.json"); JsonTranslator json = new JsonTranslator(Translator.CurrentDocType.Json, Translator.FutureDocType.Json, FilePath); json.Translate(Translator.FutureDocType.Json); Clipboard.SetText(FilePath); //SampleCodePages.Content = new SampleCodePage(FilePath); }
public void ConvertJson() { // Arrange const string json = "{ \"Name\": \"Test\", \"Valid\": true }"; // Act var translator = new JsonTranslator(typeof (ComplexType)); var result = translator.Translate(json); // Assert Assert.IsNotNull(result); Assert.IsInstanceOf<ComplexType>(result); }
public void ConvertJsonWithValidProperties() { // Arrange const string json = "{ \"Name\": \"Test\", \"Valid\": true }"; // Act var translator = new JsonTranslator(typeof(ComplexType)); dynamic result = translator.Translate(json); // Assert Assert.IsNotNull(result); Assert.AreEqual("Test", result.Name); Assert.AreEqual(true, result.Valid); }
public SampleCodePage(string path) { InitializeComponent(); object o = SampleCodePages.Content; if (path == "") { FilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Components\DefaultLisaResume.json"); path = FilePath; JsonTranslator json = new JsonTranslator(Translator.CurrentDocType.Json, Translator.FutureDocType.Json, FilePath); json.Translate(Translator.FutureDocType.Json); Clipboard.SetText(FilePath); } panel = new System.Windows.Forms.Panel(); host.Child = panel; dockIt("notepad.exe", path); }