From aa6fa75136d1cbbe61b221ab62bbd7e423b23203 Mon Sep 17 00:00:00 2001 From: Trevi Awater Date: Mon, 13 Jun 2022 15:51:05 +0200 Subject: [PATCH] Fixes --- .../Xamarin.Neo4j.iOS/Info.plist | 2 +- .../Managers/ConnectionStringManager.cs | 17 +++++ .../Models/Neo4jConnectionString.cs | 20 +++--- .../Pages/AddConnectionPage.xaml | 16 +++++ .../Pages/AddConnectionPage.xaml.cs | 5 +- .../Xamarin.Neo4j/Pages/ConnectionsPage.xaml | 3 +- .../Xamarin.Neo4j/Services/Neo4jService.cs | 26 +++++--- .../ViewModels/AddConnectionViewModel.cs | 62 +++++++++++++++---- .../ViewModels/ConnectionsViewModel.cs | 8 +++ .../ViewModels/SessionViewModel.cs | 10 ++- 10 files changed, 135 insertions(+), 34 deletions(-) diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist index 31c765e..472017e 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j.iOS/Info.plist @@ -27,7 +27,7 @@ CFBundleIdentifier nl.resoftware.pocketgraph CFBundleVersion - 1.0.2 + 1.0.3 UILaunchStoryboardName LaunchScreen CFBundleName diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Managers/ConnectionStringManager.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Managers/ConnectionStringManager.cs index 8e4939a..1c3ddf2 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Managers/ConnectionStringManager.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Managers/ConnectionStringManager.cs @@ -59,5 +59,22 @@ namespace Xamarin.Neo4j.Managers await SaveConnectionStrings(connectionStrings); } + + public static async Task UpdateConnectionString(Guid id, Neo4jConnectionString connectionString) + { + var connectionStrings = await GetConnectionStrings(); + + var connectionStringToUpdate = connectionStrings.FirstOrDefault(cs => cs.Id == id); + + if (connectionStringToUpdate == null) + return; + + connectionStringToUpdate.Scheme = connectionString.Scheme; + connectionStringToUpdate.Host = connectionString.Host; + connectionStringToUpdate.Username = connectionString.Username; + connectionStringToUpdate.Password = connectionString.Password; + + await SaveConnectionStrings(connectionStrings); + } } } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs index 3c79839..76fb48d 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Models/Neo4jConnectionString.cs @@ -21,23 +21,27 @@ namespace Xamarin.Neo4j.Models public string Host { get; set; } + public string Scheme { get; set; } + public string Username { get; set; } public string Password { get; set; } public Tuple ParseHost() { - if (Host.StartsWith("neo4j://")) - return new Tuple(Host, false, false); + var fullHost = Scheme + Host; + + if (fullHost.StartsWith("neo4j://")) + return new Tuple(fullHost, false, false); - if (Host.StartsWith("bolt://")) - return new Tuple(Host.Replace("bolt://", "neo4j://"), false, false); + if (fullHost.StartsWith("bolt://")) + return new Tuple(fullHost.Replace("bolt://", "neo4j://"), false, false); - if (Host.StartsWith("neo4j+s://")) - return new Tuple(Host.Replace("neo4j+s://", "neo4j://"), true, false); + if (fullHost.StartsWith("neo4j+s://")) + return new Tuple(fullHost.Replace("neo4j+s://", "neo4j://"), true, false); - if (Host.StartsWith("neo4j+ssc://")) - return new Tuple(Host.Replace("neo4j+ssc://", "neo4j://"), true, true); + if (fullHost.StartsWith("neo4j+ssc://")) + return new Tuple(fullHost.Replace("neo4j+ssc://", "neo4j://"), true, true); throw new NotSupportedException("Unknown protocol."); } diff --git a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml index 563b8e7..0a2e7c1 100644 --- a/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml +++ b/Xamarin.Neo4j/Xamarin.Neo4j/Xamarin.Neo4j/Pages/AddConnectionPage.xaml @@ -7,6 +7,22 @@ + + +