First working App with new API Class

This commit is contained in:
TheJoKlLa 2022-05-17 15:03:39 +02:00
parent 3cf84220bf
commit ec48a8b993
18 changed files with 119 additions and 204 deletions

View File

@ -10,7 +10,6 @@ using Borepin.PageModel.SetUpProcess;
using Borepin.Page.AddServerProcess; using Borepin.Page.AddServerProcess;
using Borepin.PageModel.AddServerProcess; using Borepin.PageModel.AddServerProcess;
using System; using System;
using Prism.Navigation;
using Borepin.Service.Storage; using Borepin.Service.Storage;
namespace Borepin namespace Borepin

View File

@ -21,8 +21,11 @@
</Target> </Target>
<ItemGroup> <ItemGroup>
<Compile Remove="Behaviour\**" /> <Compile Remove="Behaviour\**" />
<Compile Remove="Helpers\**" />
<EmbeddedResource Remove="Behaviour\**" /> <EmbeddedResource Remove="Behaviour\**" />
<EmbeddedResource Remove="Helpers\**" />
<None Remove="Behaviour\**" /> <None Remove="Behaviour\**" />
<None Remove="Helpers\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="1.0.702"> <PackageReference Include="Meziantou.Analyzer" Version="1.0.702">
@ -32,7 +35,6 @@
<PackageReference Include="NaturalSort.Extension" Version="3.2.0" /> <PackageReference Include="NaturalSort.Extension" Version="3.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="5.0.0" /> <PackageReference Include="NLog" Version="5.0.0" />
<PackageReference Include="Plugin.Multilingual" Version="1.0.2" />
<PackageReference Include="Prism.DryIoc.Forms" Version="8.1.97" /> <PackageReference Include="Prism.DryIoc.Forms" Version="8.1.97" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2401" /> <PackageReference Include="Xamarin.Forms" Version="5.0.0.2401" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />

View File

@ -1,45 +0,0 @@
using Plugin.Multilingual;
using System;
using System.Reflection;
using System.Resources;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.Helpers
{
[ContentProperty("Text")]
public class TranslateExtension : IMarkupExtension
{
const string _ResourceId = "Borepin.Resources.Text.TextResource";
static readonly Lazy<ResourceManager> _Resmgr = new Lazy<ResourceManager>(() => new ResourceManager(_ResourceId, typeof(TranslateExtension).GetTypeInfo().Assembly));
public string Text { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
if (Text == null)
{
return "";
}
System.Globalization.CultureInfo ci = CrossMultilingual.Current.CurrentCultureInfo;
string translation = _Resmgr.Value.GetString(Text, ci);
if (translation == null)
{
#if DEBUG
//throw new ArgumentException(
// String.Format("Key '{0}' was not found in resources '{1}' for culture '{2}'.", Text, ResourceId, ci.Name),
// "Text");
translation = "!MISSING TEXT!";
#else
translation = Text; // returns the key, which GETS DISPLAYED TO THE USER
#endif
}
return translation;
}
}
}

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="BOREPIN/PROPERTIES/RESOURCES.RESX" tool-id="MultilingualAppToolkit" product-name="n/a" product-version="n/a" build-num="n/a">
<header>
<tool tool-id="MultilingualAppToolkit" tool-name="Multilingual App Toolkit" tool-version="4.0.6916.0" tool-company="Microsoft" />
</header>
<body>
<group id="BOREPIN/PROPERTIES/RESOURCES.RESX" datatype="resx" />
</body>
</file>
<file datatype="xml" source-language="en" target-language="de" original="BOREPIN/RESOURCES/TEXT/TEXTRESOURCE.RESX" tool-id="MultilingualAppToolkit" product-name="n/a" product-version="n/a" build-num="n/a">
<header>
<tool tool-id="MultilingualAppToolkit" tool-name="Multilingual App Toolkit" tool-version="4.0.6916.0" tool-company="Microsoft" />
</header>
<body>
<group id="BOREPIN/RESOURCES/TEXT/TEXTRESOURCE.RESX" datatype="resx">
<trans-unit id="SetUp_WelcomePage_Text" translate="yes" xml:space="preserve">
<source>Automate your Space with FabAccess</source>
<target state="new">Automate your Space with FabAccess</target>
</trans-unit>
<trans-unit id="SetUp_WelcomePage_Title" translate="yes" xml:space="preserve">
<source>Welcome</source>
<target state="new">Welcome</target>
</trans-unit>
<trans-unit id="SetUp_WelcomePage_Button" translate="yes" xml:space="preserve">
<source>Begin working</source>
<target state="new">Begin working</target>
</trans-unit>
<trans-unit id="SetUp_ScanPage_Button" translate="yes" xml:space="preserve">
<source>Login to your Space</source>
<target state="new">Login to your Space</target>
</trans-unit>
<trans-unit id="SetUp_ScanPage_Text" translate="yes" xml:space="preserve">
<source>Wenn du dieses Logo siehst, dann kannst du es scannen</source>
<target state="new">Wenn du dieses Logo siehst, dann kannst du es scannen</target>
</trans-unit>
</group>
</body>
</file>
</xliff>

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="en" original="BOREPIN/PROPERTIES/RESOURCES.RESX" tool-id="MultilingualAppToolkit" product-name="n/a" product-version="n/a" build-num="n/a">
<header>
<tool tool-id="MultilingualAppToolkit" tool-name="Multilingual App Toolkit" tool-version="4.0.6916.0" tool-company="Microsoft" />
</header>
<body>
<group id="BOREPIN/PROPERTIES/RESOURCES.RESX" datatype="resx" />
</body>
</file>
<file datatype="xml" source-language="en" target-language="en" original="BOREPIN/RESOURCES/TEXT/TEXTRESOURCE.RESX" tool-id="MultilingualAppToolkit" product-name="n/a" product-version="n/a" build-num="n/a">
<header>
<tool tool-id="MultilingualAppToolkit" tool-name="Multilingual App Toolkit" tool-version="4.0.6916.0" tool-company="Microsoft" />
</header>
<body>
<group id="BOREPIN/RESOURCES/TEXT/TEXTRESOURCE.RESX" datatype="resx">
<trans-unit id="SetUp_WelcomePage_Text" translate="yes" xml:space="preserve">
<source>Automate your Space with FabAccess</source>
<target state="new">Automate your Space with FabAccess</target>
</trans-unit>
<trans-unit id="SetUp_WelcomePage_Title" translate="yes" xml:space="preserve">
<source>Welcome</source>
<target state="new">Welcome</target>
</trans-unit>
<trans-unit id="SetUp_WelcomePage_Button" translate="yes" xml:space="preserve">
<source>Begin working</source>
<target state="new">Begin working</target>
</trans-unit>
<trans-unit id="SetUp_ScanPage_Button" translate="yes" xml:space="preserve">
<source>Login to your Space</source>
<target state="new">Login to your Space</target>
</trans-unit>
<trans-unit id="SetUp_ScanPage_Text" translate="yes" xml:space="preserve">
<source>Wenn du dieses Logo siehst, dann kannst du es scannen</source>
<target state="new">Wenn du dieses Logo siehst, dann kannst du es scannen</target>
</trans-unit>
</group>
</body>
</file>
</xliff>

View File

@ -16,7 +16,7 @@
</StackLayout> </StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}"> <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="Host" Style="{StaticResource Style_Label_Property_Title}"></Label> <Label Text="Host" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Server}" Keyboard="Url" IsSpellCheckEnabled="false"/> <Entry Text="{Binding Host}" Keyboard="Url" IsSpellCheckEnabled="false"/>
<Button Text="Connect to Server" Command="{Binding ConnectToServerCommand}" Style="{StaticResource Style_Button_Primary}"/> <Button Text="Connect to Server" Command="{Binding ConnectToServerCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="Scan QR-Code" Command="{Binding ScanCodeCommand}" Style="{StaticResource Style_Button_Primary}"> <Button Text="Scan QR-Code" Command="{Binding ScanCodeCommand}" Style="{StaticResource Style_Button_Primary}">
<Button.IsVisible> <Button.IsVisible>

View File

@ -2,14 +2,14 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.SetUpProcess.WelcomePage" x:Class="Borepin.Page.SetUpProcess.WelcomePage"
xmlns:i18n="clr-namespace:Borepin.Helpers" xmlns:resource="clr-namespace:Borepin.Resources.Text"
Title="FabAccess"> Title="FabAccess">
<ContentPage.Content> <ContentPage.Content>
<ScrollView> <ScrollView>
<StackLayout Style="{StaticResource Style_StackLayout_Content}"> <StackLayout Style="{StaticResource Style_StackLayout_Content}">
<Label Text="{i18n:Translate SetUp_WelcomePage_Title}" Style="{StaticResource Style_Label_Title_Center}"/> <Label Text="{x:Static resource:TextResource.SetUp_WelcomePage_Title}" Style="{StaticResource Style_Label_Title_Center}"/>
<Label Text="{i18n:Translate SetUp_WelcomePage_Text}" Style="{StaticResource Style_Label_Text_Center}"/> <Label Text="{x:Static resource:TextResource.SetUp_WelcomePage_Text}" Style="{StaticResource Style_Label_Text_Center}"/>
<Button Text="{i18n:Translate SetUp_WelcomePage_Button}" Command="{Binding NextCommand}" Style="{StaticResource Style_Button_Primary}"/> <Button Text="{x:Static resource:TextResource.SetUp_WelcomePage_Button}" Command="{Binding NextCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>
</ContentPage.Content> </ContentPage.Content>

View File

@ -5,11 +5,13 @@ using System.Windows.Input;
using Borepin.Base; using Borepin.Base;
using Borepin.Base.Exceptions; using Borepin.Base.Exceptions;
using Borepin.Service; using Borepin.Service;
using Borepin.Service.Storage;
using FabAccessAPI; using FabAccessAPI;
using FabAccessAPI.Exceptions; using FabAccessAPI.Exceptions;
using Prism.Commands; using Prism.Commands;
using Prism.Navigation; using Prism.Navigation;
using Prism.Services; using Prism.Services;
using Xamarin.Forms;
namespace Borepin.PageModel.AddServerProcess namespace Borepin.PageModel.AddServerProcess
{ {
@ -17,11 +19,14 @@ namespace Borepin.PageModel.AddServerProcess
{ {
#region Private Fields #region Private Fields
private ConnectionData _ConnectionData; private ConnectionData _ConnectionData;
private readonly ILoginStorageService _LoginStorageService;
#endregion #endregion
#region Constructors #region Constructors
public AuthPlainPageModel(INavigationService navigationService, IAPIService apiService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService, apiService) public AuthPlainPageModel(INavigationService navigationService, IAPIService apiService, IPageDialogService pageDialogService, ILoginStorageService loginStorageService) : base(navigationService, pageDialogService, apiService)
{ {
_LoginStorageService = loginStorageService;
AuthenticateCommand = new DelegateCommand(async () => await AuthenticateCommandExecute().ConfigureAwait(false)); AuthenticateCommand = new DelegateCommand(async () => await AuthenticateCommandExecute().ConfigureAwait(false));
} }
#endregion #endregion
@ -77,19 +82,19 @@ namespace Borepin.PageModel.AddServerProcess
Username = Username, Username = Username,
Properties = new Dictionary<string, object>(StringComparer.Ordinal) Properties = new Dictionary<string, object>(StringComparer.Ordinal)
{ {
{ "username", Username }, { "Username", Username },
{ "password", Password }, { "Password", Password },
}, },
}; };
if (_API.IsConnected) if (_API.IsConnected)
{ {
await _API.Disconnect().ConfigureAwait(true); await _API.Disconnect().ConfigureAwait(false);
} }
try try
{ {
await _API.Connect(_ConnectionData).ConfigureAwait(true); await _API.Connect(_ConnectionData).ConfigureAwait(false);
} }
catch (ConnectingFailedException) catch (ConnectingFailedException)
{ {
@ -113,11 +118,17 @@ namespace Borepin.PageModel.AddServerProcess
return; return;
} }
await _LoginStorageService.Add(_ConnectionData).ConfigureAwait(false);
await _LoginStorageService.UpdateTimestamp(_ConnectionData).ConfigureAwait(false);
Device.BeginInvokeOnMainThread(async () =>
{
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage").ConfigureAwait(false); INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage").ConfigureAwait(false);
if(result.Exception != null) if (result.Exception != null)
{ {
Log.Fatal(result.Exception, "Navigating failed"); Log.Fatal(result.Exception, "Navigating failed");
} }
});
} }
#endregion #endregion
} }

View File

@ -1,5 +1,4 @@
using Borepin.Base; using Borepin.Base;
using Borepin.Service;
using FabAccessAPI; using FabAccessAPI;
using FabAccessAPI.Exceptions; using FabAccessAPI.Exceptions;
using Prism.Commands; using Prism.Commands;

View File

@ -107,7 +107,7 @@ namespace Borepin.PageModel
NavigationParameters parameters = new NavigationParameters NavigationParameters parameters = new NavigationParameters
{ {
{ "id", viewmodel.Instance.Id }, { "instance", viewmodel.Instance.Id },
}; };
await _NavigationService.NavigateAsync($"MachinePage", parameters).ConfigureAwait(false); await _NavigationService.NavigateAsync($"MachinePage", parameters).ConfigureAwait(false);

View File

@ -31,8 +31,8 @@ namespace Borepin.PageModel
} }
#endregion #endregion
#region Data #region LoadData
public async Task LoadData() public override async Task LoadInstance(object instance)
{ {
IList<ConnectionData> list = await _LoginStorageService.GetList().ConfigureAwait(false); IList<ConnectionData> list = await _LoginStorageService.GetList().ConfigureAwait(false);
if (_API.IsConnected) if (_API.IsConnected)

View File

@ -12,6 +12,7 @@ using System;
using System.Globalization; using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
@ -123,11 +124,16 @@ namespace Borepin.PageModel
return; return;
} }
await _LoginStorageService.UpdateTimestamp(_Connection_Item).ConfigureAwait(false);
Device.BeginInvokeOnMainThread(async () =>
{
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage").ConfigureAwait(false); INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage").ConfigureAwait(false);
if(result.Exception != null) if (result.Exception != null)
{ {
Log.Fatal(result.Exception, "Navigating failed"); Log.Fatal(result.Exception, "Navigating failed");
} }
});
} }
private ICommand _DisconnectCommand; private ICommand _DisconnectCommand;

View File

@ -5,6 +5,7 @@ using Prism.AppModel;
using Prism.Navigation; using Prism.Navigation;
using Prism.Services; using Prism.Services;
using System.Collections.Generic; using System.Collections.Generic;
using Xamarin.Forms;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
@ -26,20 +27,26 @@ namespace Borepin.PageModel
{ {
IList<ConnectionData> connectionData_List = await _LoginStorageService.GetList().ConfigureAwait(false); IList<ConnectionData> connectionData_List = await _LoginStorageService.GetList().ConfigureAwait(false);
if (connectionData_List.Count == 0) if (connectionData_List.Count == 0)
{
Device.BeginInvokeOnMainThread(async () =>
{ {
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/SetUpProcess_WelcomePage").ConfigureAwait(false); INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/SetUpProcess_WelcomePage").ConfigureAwait(false);
if (result.Exception != null) if (result.Exception != null)
{ {
Log.Fatal(result.Exception, "Navigating failed"); Log.Fatal(result.Exception, "Navigating failed");
} }
});
} }
else else
{
Device.BeginInvokeOnMainThread(async () =>
{ {
INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage").ConfigureAwait(false); INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage").ConfigureAwait(false);
if (result.Exception != null) if (result.Exception != null)
{ {
Log.Fatal(result.Exception, "Navigating failed"); Log.Fatal(result.Exception, "Navigating failed");
} }
});
} }
} }

View File

@ -10,35 +10,48 @@
namespace Borepin.Resources.Text { namespace Borepin.Resources.Text {
using System; using System;
using System.Reflection;
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] /// <summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()] /// A strongly-typed resource class, for looking up localized strings, etc.
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()] /// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class TextResource { internal class TextResource {
private static System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal TextResource() { internal TextResource() {
} }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] /// <summary>
internal static System.Resources.ResourceManager ResourceManager { /// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.Equals(null, resourceMan)) { if (object.ReferenceEquals(resourceMan, null)) {
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Borepin.Resources.Text.TextResource", typeof(TextResource).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Borepin.Resources.Text.TextResource", typeof(TextResource).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;
} }
} }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] /// <summary>
internal static System.Globalization.CultureInfo Culture { /// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get { get {
return resourceCulture; return resourceCulture;
} }
@ -47,30 +60,36 @@ namespace Borepin.Resources.Text {
} }
} }
/// <summary>
/// Looks up a localized string similar to Login to your Space.
/// </summary>
internal static string SetUp_ScanPage_Button { internal static string SetUp_ScanPage_Button {
get { get {
return ResourceManager.GetString("SetUp_ScanPage_Button", resourceCulture); return ResourceManager.GetString("SetUp_ScanPage_Button", resourceCulture);
} }
} }
internal static string SetUp_ScanPage_Text { /// <summary>
get { /// Looks up a localized string similar to Begin working.
return ResourceManager.GetString("SetUp_ScanPage_Text", resourceCulture); /// </summary>
}
}
internal static string SetUp_WelcomePage_Button { internal static string SetUp_WelcomePage_Button {
get { get {
return ResourceManager.GetString("SetUp_WelcomePage_Button", resourceCulture); return ResourceManager.GetString("SetUp_WelcomePage_Button", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Automate your Space with FabAccess.
/// </summary>
internal static string SetUp_WelcomePage_Text { internal static string SetUp_WelcomePage_Text {
get { get {
return ResourceManager.GetString("SetUp_WelcomePage_Text", resourceCulture); return ResourceManager.GetString("SetUp_WelcomePage_Text", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Welcome.
/// </summary>
internal static string SetUp_WelcomePage_Title { internal static string SetUp_WelcomePage_Title {
get { get {
return ResourceManager.GetString("SetUp_WelcomePage_Title", resourceCulture); return ResourceManager.GetString("SetUp_WelcomePage_Title", resourceCulture);

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -120,9 +120,6 @@
<data name="SetUp_ScanPage_Button" xml:space="preserve"> <data name="SetUp_ScanPage_Button" xml:space="preserve">
<value>Login to your Space</value> <value>Login to your Space</value>
</data> </data>
<data name="SetUp_ScanPage_Text" xml:space="preserve">
<value>Wenn du dieses Logo siehst, dann kannst du es scannen</value>
</data>
<data name="SetUp_WelcomePage_Button" xml:space="preserve"> <data name="SetUp_WelcomePage_Button" xml:space="preserve">
<value>Begin working</value> <value>Begin working</value>
</data> </data>

View File

@ -4,6 +4,7 @@ using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Linq;
namespace Borepin.Service.Storage namespace Borepin.Service.Storage
{ {
@ -53,13 +54,13 @@ namespace Borepin.Service.Storage
throw new InvalidConnectionExceptoin(connectionData); throw new InvalidConnectionExceptoin(connectionData);
} }
IList<ConnectionData> connectionData_List = await _LoadConnectionData().ConfigureAwait(false); List<ConnectionData> connectionData_List = new List<ConnectionData>(await _LoadConnectionData().ConfigureAwait(false));
if (connectionData_List.Contains(connectionData)) if (connectionData_List.Contains(connectionData))
{ {
throw new MissingConnectionException(connectionData); throw new MissingConnectionException(connectionData);
} }
connectionData_List.Remove(connectionData); connectionData_List.RemoveAll(x => x.Equals(connectionData));
await _SaveConnectionData(connectionData_List).ConfigureAwait(false); await _SaveConnectionData(connectionData_List).ConfigureAwait(false);
} }
@ -70,7 +71,7 @@ namespace Borepin.Service.Storage
throw new InvalidConnectionExceptoin(connectionData); throw new InvalidConnectionExceptoin(connectionData);
} }
IList<ConnectionData> connectionData_List = await _LoadConnectionData().ConfigureAwait(false); List<ConnectionData> connectionData_List = new List<ConnectionData>(await _LoadConnectionData().ConfigureAwait(false));
if (connectionData_List.Contains(connectionData)) if (connectionData_List.Contains(connectionData))
{ {
throw new MissingConnectionException(connectionData); throw new MissingConnectionException(connectionData);
@ -78,7 +79,7 @@ namespace Borepin.Service.Storage
connectionData.LastTime = DateTime.UtcNow; connectionData.LastTime = DateTime.UtcNow;
connectionData_List.Remove(connectionData); connectionData_List.RemoveAll(x => x.Equals(connectionData));
connectionData_List.Add(connectionData); connectionData_List.Add(connectionData);
await _SaveConnectionData(connectionData_List).ConfigureAwait(false); await _SaveConnectionData(connectionData_List).ConfigureAwait(false);
} }
@ -91,8 +92,16 @@ namespace Borepin.Service.Storage
try try
{ {
string data = await _SecretStorageService.GetAsync(StorageKey).ConfigureAwait(false); string data = await _SecretStorageService.GetAsync(StorageKey).ConfigureAwait(false);
if(data != null)
{
connectionData_List = JsonConvert.DeserializeObject<List<ConnectionData>>(data); connectionData_List = JsonConvert.DeserializeObject<List<ConnectionData>>(data);
} }
else
{
connectionData_List = new List<ConnectionData>();
await _SecretStorageService.SetAsync(StorageKey, JsonConvert.SerializeObject(connectionData_List)).ConfigureAwait(false);
}
}
catch (JsonSerializationException) catch (JsonSerializationException)
{ {
connectionData_List = new List<ConnectionData>(); connectionData_List = new List<ConnectionData>();

View File

@ -13,11 +13,17 @@ namespace FabAccessAPI
public override bool Equals(object? obj) public override bool Equals(object? obj)
{ {
return obj is ConnectionData data && if(obj is ConnectionData && obj != null)
EqualityComparer<Uri>.Default.Equals(Host, data.Host) && {
Mechanism == data.Mechanism && ConnectionData? data = obj as ConnectionData;
Username == data.Username && return data.Host.Host == Host.Host &&
data.Host.Port == Host.Port &&
data.Mechanism == Mechanism &&
data.Username == Username &&
EqualityComparer<Dictionary<string, object>>.Default.Equals(Properties, data.Properties); EqualityComparer<Dictionary<string, object>>.Default.Equals(Properties, data.Properties);
}
return false;
} }
public override int GetHashCode() public override int GetHashCode()