private bool LoadVersionsFile() { try { versionService.AllVersions = JsonConverterService <List <GodotVersion> > .Deserialize("config\\versions.json"); string installedManifest = $"{config.GodotInstallLocation}\\manifest.json"; if (config.GodotInstallLocation != String.Empty && File.Exists(installedManifest)) { versionService.InstalledVersions = JsonConverterService <List <GodotVersionInstalled> > .Deserialize(installedManifest); } else { versionService.InstalledVersions = new List <GodotVersionInstalled>(); } } catch (Exception ex) { logger.Error(ex); CommonUtilsService.PopupExceptionMessage("Error loading versions", ex); return(false); } versionService.AllVersions.Reverse(); return(true); }
private void BrowseFolderButton_Click(object sender, RoutedEventArgs e) { using (var ofd = new FolderBrowserDialog()) { ofd.RootFolder = Environment.SpecialFolder.MyComputer; ofd.ShowNewFolderButton = true; if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } string path = ofd.SelectedPath; string manifestFile = $"{path}\\manifest.json"; if (!File.Exists(manifestFile)) { using (var file = File.CreateText(manifestFile)) { file.Write("[]"); } } versionService.InstalledVersions = JsonConverterService <List <GodotVersionInstalled> > .Deserialize(manifestFile); GodotInstallLocationTextbox.Text = path; } }
private bool ReadOrCreateConfigFile() { string configFile = "config\\config.json"; try { if (!File.Exists(configFile)) { config = new ApplicationConfig { GodotInstallLocation = String.Empty, Show32BitVersions = true, Show64BitVersions = true, ShowMonoVersions = false, ShowUnstableVersions = false, ShowInstalledVersions = true, ShowNotInstalledVersions = true, ShowStableVersions = true, ShowStandardVersions = true, LastUpdateChecked = DateTime.Now, LastSelectedVersion = -1, OnGodotLaunch = Constants.DO_NOTHING_ON_LAUNCH, UseProxy = false, ProxyUrl = String.Empty, ProxyPort = 0, }; JsonConverterService <ApplicationConfig> .Serialize(config, configFile); } config = JsonConverterService <ApplicationConfig> .Deserialize(configFile); if (config.UseProxy && (config.ProxyPort == 0 || config.ProxyUrl == String.Empty)) { config.UseProxy = false; JsonConverterService <ApplicationConfig> .Serialize(config, configFile); } if (config.GodotInstallLocation != String.Empty && !Directory.Exists(config.GodotInstallLocation)) { Directory.CreateDirectory(config.GodotInstallLocation); using (var file = File.CreateText($"{config.GodotInstallLocation}\\manifest.json")) { file.Write("[]"); } } } catch (Exception ex) { logger.Error(ex); CommonUtilsService.PopupExceptionMessage("Error reading config", ex); return(false); } return(true); }
public void CanDeserializeNullMetadataValue() { // Given: A JSON metadata value JsonConverterService jsonConverterService = new JsonConverterService(); string metadataJson = @"null"; string paymentJson = @"{""metadata"":" + metadataJson + "}"; // When: We deserialize the JSON PaymentResponse payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.AreEqual(null, payments.Metadata); }
public void CanDeserializeNullMetadataValue() { // Given: A JSON metadata value var jsonConverterService = new JsonConverterService(); var metadataJson = @"null"; var paymentJson = @"{""metadata"":" + metadataJson + "}"; // When: We deserialize the JSON var payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.Null(payments.Metadata); }
public void CanDeserializeStringMetadataValue() { // Given: A JSON metadata value var jsonConverterService = new JsonConverterService(); var metadataJson = "This is my metadata"; var paymentJson = @"{""metadata"":""" + metadataJson + @"""}"; // When: We deserialize the JSON var payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.Equal(metadataJson, payments.Metadata); }
public void Deserialize_StringData_IsDeserialized() { // Given: A JSON metadata value JsonConverterService jsonConverterService = new JsonConverterService(); string metadataJson = "This is my metadata"; string paymentJson = @"{""metadata"":""" + metadataJson + @"""}"; // When: We deserialize the JSON PaymentResponse payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.AreEqual(metadataJson, payments.Metadata); }
public void CanDeserializeJsonMetadata() { // Given: A JSON metadata value JsonConverterService jsonConverterService = new JsonConverterService(); string metadataJson = @"{ ""ReferenceNumber"": null, ""OrderID"": null, ""UserID"": ""534721"" }"; string paymentJson = @"{""metadata"":" + metadataJson + "}"; // When: We deserialize the JSON PaymentResponse payments = jsonConverterService.Deserialize <PaymentResponse>(paymentJson); // Then: Assert.AreEqual(metadataJson, payments.Metadata); }