mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 23:01:52 +01:00
Added: IPlatformInitializer
This commit is contained in:
parent
effc059fa7
commit
5e0dd63bf9
@ -62,8 +62,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="MainActivity.cs" />
|
<Compile Include="MainActivity.cs" />
|
||||||
<Compile Include="MainApplication.cs" />
|
<Compile Include="MainApplication.cs" />
|
||||||
|
<Compile Include="PlatformInitializer.cs" />
|
||||||
<Compile Include="Resources\Resource.designer.cs" />
|
<Compile Include="Resources\Resource.designer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Services\PreferenceService.cs" />
|
||||||
|
<Compile Include="Services\SecretService.cs" />
|
||||||
<Compile Include="SplashActivity.cs" />
|
<Compile Include="SplashActivity.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -16,7 +16,7 @@ namespace Borepin.Droid
|
|||||||
base.OnCreate(savedInstanceState);
|
base.OnCreate(savedInstanceState);
|
||||||
|
|
||||||
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||||
LoadApplication(new App());
|
LoadApplication(new App(new PlatformInitializer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
16
Borepin/Borepin.Android/PlatformInitializer.cs
Normal file
16
Borepin/Borepin.Android/PlatformInitializer.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Borepin.Droid.Services;
|
||||||
|
using Borepin.Service;
|
||||||
|
using Prism;
|
||||||
|
using Prism.Ioc;
|
||||||
|
|
||||||
|
namespace Borepin.Droid
|
||||||
|
{
|
||||||
|
public class PlatformInitializer : IPlatformInitializer
|
||||||
|
{
|
||||||
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||||
|
{
|
||||||
|
containerRegistry.Register<IPreferenceService, PreferenceService>();
|
||||||
|
containerRegistry.Register<ISecretService, SecretService>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1900
Borepin/Borepin.Android/Resources/Resource.designer.cs
generated
1900
Borepin/Borepin.Android/Resources/Resource.designer.cs
generated
File diff suppressed because it is too large
Load Diff
33
Borepin/Borepin.Android/Services/PreferenceService.cs
Normal file
33
Borepin/Borepin.Android/Services/PreferenceService.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using Borepin.Service;
|
||||||
|
using Xamarin.Essentials;
|
||||||
|
|
||||||
|
namespace Borepin.Droid.Services
|
||||||
|
{
|
||||||
|
public class PreferenceService : IPreferenceService
|
||||||
|
{
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
Preferences.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey(string key)
|
||||||
|
{
|
||||||
|
return Preferences.ContainsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Get(string key, string defaultValue)
|
||||||
|
{
|
||||||
|
return Preferences.Get(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
Preferences.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(string key, string value)
|
||||||
|
{
|
||||||
|
Preferences.Set(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
Borepin/Borepin.Android/Services/SecretService.cs
Normal file
29
Borepin/Borepin.Android/Services/SecretService.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Borepin.Service;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Essentials;
|
||||||
|
|
||||||
|
namespace Borepin.Droid.Services
|
||||||
|
{
|
||||||
|
public class SecretService : ISecretService
|
||||||
|
{
|
||||||
|
public Task<string> GetAsync(string key)
|
||||||
|
{
|
||||||
|
return SecureStorage.GetAsync(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(string key)
|
||||||
|
{
|
||||||
|
return SecureStorage.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAll()
|
||||||
|
{
|
||||||
|
SecureStorage.RemoveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SetAsync(string key, string value)
|
||||||
|
{
|
||||||
|
return SecureStorage.SetAsync(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -106,6 +106,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="PlatformInitializer.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
13
Borepin/Borepin.GTK/PlatformInitializer.cs
Normal file
13
Borepin/Borepin.GTK/PlatformInitializer.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using Prism;
|
||||||
|
using Prism.Ioc;
|
||||||
|
|
||||||
|
namespace Borepin.GTK
|
||||||
|
{
|
||||||
|
public class PlatformInitializer : IPlatformInitializer
|
||||||
|
{
|
||||||
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
using Borepin;
|
using System;
|
||||||
using System;
|
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Platform.GTK;
|
using Xamarin.Forms.Platform.GTK;
|
||||||
|
|
||||||
namespace GameOfLife.GTK
|
namespace Borepin.GTK
|
||||||
{
|
{
|
||||||
class MainClass
|
class MainClass
|
||||||
{
|
{
|
||||||
@ -13,10 +12,9 @@ namespace GameOfLife.GTK
|
|||||||
Gtk.Application.Init();
|
Gtk.Application.Init();
|
||||||
Forms.Init();
|
Forms.Init();
|
||||||
|
|
||||||
var app = new App();
|
|
||||||
var window = new FormsWindow();
|
var window = new FormsWindow();
|
||||||
window.LoadApplication(app);
|
window.LoadApplication(new App(new PlatformInitializer()));
|
||||||
window.SetApplicationTitle("Game of Life");
|
window.SetApplicationTitle("FabAccess");
|
||||||
window.Show();
|
window.Show();
|
||||||
|
|
||||||
Gtk.Application.Run();
|
Gtk.Application.Run();
|
||||||
|
@ -95,7 +95,10 @@
|
|||||||
<Compile Include="MainPage.xaml.cs">
|
<Compile Include="MainPage.xaml.cs">
|
||||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="PlatformInitializer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Services\PreferenceService.cs" />
|
||||||
|
<Compile Include="Services\SecretService.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AppxManifest Include="Package.appxmanifest">
|
<AppxManifest Include="Package.appxmanifest">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
|
|
||||||
LoadApplication(new Borepin.App());
|
LoadApplication(new Borepin.App(new PlatformInitializer()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
Borepin/Borepin.UWP/PlatformInitializer.cs
Normal file
16
Borepin/Borepin.UWP/PlatformInitializer.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Borepin.UWP.Services;
|
||||||
|
using Borepin.Service;
|
||||||
|
using Prism;
|
||||||
|
using Prism.Ioc;
|
||||||
|
|
||||||
|
namespace Borepin.UWP
|
||||||
|
{
|
||||||
|
public class PlatformInitializer : IPlatformInitializer
|
||||||
|
{
|
||||||
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||||
|
{
|
||||||
|
containerRegistry.Register<IPreferenceService, PreferenceService>();
|
||||||
|
containerRegistry.Register<ISecretService, SecretService>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
Borepin/Borepin.UWP/Services/PreferenceService.cs
Normal file
33
Borepin/Borepin.UWP/Services/PreferenceService.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using Borepin.Service;
|
||||||
|
using Xamarin.Essentials;
|
||||||
|
|
||||||
|
namespace Borepin.UWP.Services
|
||||||
|
{
|
||||||
|
public class PreferenceService : IPreferenceService
|
||||||
|
{
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
Preferences.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey(string key)
|
||||||
|
{
|
||||||
|
return Preferences.ContainsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Get(string key, string defaultValue)
|
||||||
|
{
|
||||||
|
return Preferences.Get(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
Preferences.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(string key, string value)
|
||||||
|
{
|
||||||
|
Preferences.Set(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
Borepin/Borepin.UWP/Services/SecretService.cs
Normal file
29
Borepin/Borepin.UWP/Services/SecretService.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Borepin.Service;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Essentials;
|
||||||
|
|
||||||
|
namespace Borepin.UWP.Services
|
||||||
|
{
|
||||||
|
public class SecretService : ISecretService
|
||||||
|
{
|
||||||
|
public Task<string> GetAsync(string key)
|
||||||
|
{
|
||||||
|
return SecureStorage.GetAsync(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(string key)
|
||||||
|
{
|
||||||
|
return SecureStorage.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAll()
|
||||||
|
{
|
||||||
|
SecureStorage.RemoveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SetAsync(string key, string value)
|
||||||
|
{
|
||||||
|
return SecureStorage.SetAsync(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
|
using Foundation;
|
||||||
using Foundation;
|
|
||||||
using UIKit;
|
using UIKit;
|
||||||
|
|
||||||
namespace Borepin.iOS
|
namespace Borepin.iOS
|
||||||
@ -20,7 +19,7 @@ namespace Borepin.iOS
|
|||||||
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
||||||
{
|
{
|
||||||
global::Xamarin.Forms.Forms.Init();
|
global::Xamarin.Forms.Forms.Init();
|
||||||
LoadApplication(new App());
|
LoadApplication(new App(new PlatformInitializer()));
|
||||||
|
|
||||||
return base.FinishedLaunching(app, options);
|
return base.FinishedLaunching(app, options);
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="AppDelegate.cs" />
|
<Compile Include="AppDelegate.cs" />
|
||||||
|
<Compile Include="Services\PreferenceService.cs" />
|
||||||
|
<Compile Include="Services\SecretService.cs" />
|
||||||
<None Include="Entitlements.plist" />
|
<None Include="Entitlements.plist" />
|
||||||
<None Include="Info.plist" />
|
<None Include="Info.plist" />
|
||||||
|
<Compile Include="PlatformInitializer.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="CNFC\Card.cs" />
|
<Compile Include="CNFC\Card.cs" />
|
||||||
<Compile Include="CNFC\Hardware.cs" />
|
<Compile Include="CNFC\Hardware.cs" />
|
||||||
|
16
Borepin/Borepin.iOS/PlatformInitializer.cs
Normal file
16
Borepin/Borepin.iOS/PlatformInitializer.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Borepin.iOS.Services;
|
||||||
|
using Borepin.Service;
|
||||||
|
using Prism;
|
||||||
|
using Prism.Ioc;
|
||||||
|
|
||||||
|
namespace Borepin.iOS
|
||||||
|
{
|
||||||
|
public class PlatformInitializer : IPlatformInitializer
|
||||||
|
{
|
||||||
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||||
|
{
|
||||||
|
containerRegistry.Register<IPreferenceService, PreferenceService>();
|
||||||
|
containerRegistry.Register<ISecretService, SecretService>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
Borepin/Borepin.iOS/Services/PreferenceService.cs
Normal file
33
Borepin/Borepin.iOS/Services/PreferenceService.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using Borepin.Service;
|
||||||
|
using Xamarin.Essentials;
|
||||||
|
|
||||||
|
namespace Borepin.iOS.Services
|
||||||
|
{
|
||||||
|
public class PreferenceService : IPreferenceService
|
||||||
|
{
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
Preferences.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey(string key)
|
||||||
|
{
|
||||||
|
return Preferences.ContainsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Get(string key, string defaultValue)
|
||||||
|
{
|
||||||
|
return Preferences.Get(key, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
Preferences.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(string key, string value)
|
||||||
|
{
|
||||||
|
Preferences.Set(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
Borepin/Borepin.iOS/Services/SecretService.cs
Normal file
29
Borepin/Borepin.iOS/Services/SecretService.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Borepin.Service;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Essentials;
|
||||||
|
|
||||||
|
namespace Borepin.iOS.Services
|
||||||
|
{
|
||||||
|
public class SecretService : ISecretService
|
||||||
|
{
|
||||||
|
public Task<string> GetAsync(string key)
|
||||||
|
{
|
||||||
|
return SecureStorage.GetAsync(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(string key)
|
||||||
|
{
|
||||||
|
return SecureStorage.Remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAll()
|
||||||
|
{
|
||||||
|
SecureStorage.RemoveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SetAsync(string key, string value)
|
||||||
|
{
|
||||||
|
return SecureStorage.SetAsync(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,15 +8,17 @@ namespace Borepin.macOS
|
|||||||
[Register("AppDelegate")]
|
[Register("AppDelegate")]
|
||||||
public class AppDelegate : FormsApplicationDelegate
|
public class AppDelegate : FormsApplicationDelegate
|
||||||
{
|
{
|
||||||
NSWindow window;
|
readonly NSWindow window;
|
||||||
public AppDelegate()
|
public AppDelegate()
|
||||||
{
|
{
|
||||||
var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
|
var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
|
||||||
|
|
||||||
var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);
|
var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);
|
||||||
window = new NSWindow(rect, style, NSBackingStore.Buffered, false);
|
window = new NSWindow(rect, style, NSBackingStore.Buffered, false)
|
||||||
window.Title = "Xamarin.Forms on Mac!"; // choose your own Title here
|
{
|
||||||
window.TitleVisibility = NSWindowTitleVisibility.Hidden;
|
Title = "Xamarin.Forms on Mac!", // choose your own Title here
|
||||||
|
TitleVisibility = NSWindowTitleVisibility.Hidden
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override NSWindow MainWindow
|
public override NSWindow MainWindow
|
||||||
@ -27,7 +29,7 @@ namespace Borepin.macOS
|
|||||||
public override void DidFinishLaunching(NSNotification notification)
|
public override void DidFinishLaunching(NSNotification notification)
|
||||||
{
|
{
|
||||||
Forms.Init();
|
Forms.Init();
|
||||||
LoadApplication(new App());
|
LoadApplication(new App(new PlatformInitializer()));
|
||||||
base.DidFinishLaunching(notification);
|
base.DidFinishLaunching(notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="AppDelegate.cs" />
|
<Compile Include="AppDelegate.cs" />
|
||||||
|
<Compile Include="PlatformInitializer.cs" />
|
||||||
<Compile Include="ViewController.cs" />
|
<Compile Include="ViewController.cs" />
|
||||||
<Compile Include="ViewController.designer.cs">
|
<Compile Include="ViewController.designer.cs">
|
||||||
<DependentUpon>ViewController.cs</DependentUpon>
|
<DependentUpon>ViewController.cs</DependentUpon>
|
||||||
|
13
Borepin/Borepin.macOS/PlatformInitializer.cs
Normal file
13
Borepin/Borepin.macOS/PlatformInitializer.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using Prism;
|
||||||
|
using Prism.Ioc;
|
||||||
|
|
||||||
|
namespace Borepin.macOS
|
||||||
|
{
|
||||||
|
public class PlatformInitializer : IPlatformInitializer
|
||||||
|
{
|
||||||
|
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,17 +9,13 @@ using Borepin.Service.BFFH;
|
|||||||
using Borepin.Service.Credentials;
|
using Borepin.Service.Credentials;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Borepin.Model;
|
using Borepin.Model;
|
||||||
|
using Prism;
|
||||||
|
|
||||||
namespace Borepin
|
namespace Borepin
|
||||||
{
|
{
|
||||||
public partial class App
|
public partial class App
|
||||||
{
|
{
|
||||||
private IConnectionService _ConnectionService;
|
public App(IPlatformInitializer platformInitializer) : base(platformInitializer)
|
||||||
private ICredentialService _CredentialService;
|
|
||||||
private IBFFHService _BFFHService;
|
|
||||||
|
|
||||||
|
|
||||||
public App()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -28,18 +24,7 @@ namespace Borepin
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Prism.Navigation.INavigationResult result;
|
Prism.Navigation.INavigationResult result = await NavigationService.NavigateAsync("/MainPage/NavigationPage/TestPage");
|
||||||
List<Connection> connection_list = await _ConnectionService.GetConnectionList();
|
|
||||||
if (connection_list.Count == 0)
|
|
||||||
{
|
|
||||||
result = await NavigationService.NavigateAsync("/NavigationPage/HostSelectPage");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = await NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage");
|
|
||||||
}
|
|
||||||
|
|
||||||
//result = await NavigationService.NavigateAsync("/NavigationPage/TestPage");
|
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debugger.Break();
|
System.Diagnostics.Debugger.Break();
|
||||||
@ -66,13 +51,9 @@ namespace Borepin
|
|||||||
containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>();
|
containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>();
|
||||||
|
|
||||||
// Register Service
|
// Register Service
|
||||||
_ConnectionService = new ConnectionService();
|
containerRegistry.Register<IConnectionService, ConnectionService>();
|
||||||
_CredentialService = new CredentialService();
|
containerRegistry.Register<ICredentialService, CredentialService>();
|
||||||
_BFFHService = new BFFHService(_CredentialService);
|
containerRegistry.RegisterSingleton<IBFFHService, BFFHService>();
|
||||||
|
|
||||||
containerRegistry.RegisterInstance<IConnectionService>(_ConnectionService);
|
|
||||||
containerRegistry.RegisterInstance<ICredentialService>(_CredentialService);
|
|
||||||
containerRegistry.RegisterInstance<IBFFHService>(_BFFHService);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="Prism.DryIoc.Forms" Version="7.2.0.1422" />
|
<PackageReference Include="Prism.DryIoc.Forms" Version="7.2.0.1422" />
|
||||||
<PackageReference Include="Xamarin.Forms" Version="4.7.0.1351" />
|
<PackageReference Include="Xamarin.Forms" Version="4.7.0.1351" />
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
|
|
||||||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
||||||
<PackageReference Include="Xamarin.Forms.EntryAutoComplete" Version="1.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Page\MachineListPage.xaml.cs">
|
<Compile Update="Page\MachineListPage.xaml.cs">
|
||||||
@ -82,6 +80,9 @@
|
|||||||
<EmbeddedResource Update="Page\SettingsPage.xaml">
|
<EmbeddedResource Update="Page\SettingsPage.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Update="Page\SetUpProcess\WelcomePage.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Update="Page\TestPage.xaml">
|
<EmbeddedResource Update="Page\TestPage.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
12
Borepin/Borepin/Page/SetUpProcess/WelcomePage.xaml
Normal file
12
Borepin/Borepin/Page/SetUpProcess/WelcomePage.xaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="Borepin.Page.SetUpProcess.WelcomePage">
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<Label Text="Welcome to Xamarin.Forms!"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
20
Borepin/Borepin/Page/SetUpProcess/WelcomePage.xaml.cs
Normal file
20
Borepin/Borepin/Page/SetUpProcess/WelcomePage.xaml.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
namespace Borepin.Page.SetUpProcess
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class WelcomePage : ContentPage
|
||||||
|
{
|
||||||
|
public WelcomePage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -84,7 +84,7 @@ namespace Borepin.PageModel
|
|||||||
private void DetectHostCommandExecuted()
|
private void DetectHostCommandExecuted()
|
||||||
{
|
{
|
||||||
// Use Demo Host
|
// Use Demo Host
|
||||||
Host = "192.168.178.20:59661";
|
Host = "127.0.0.1:59661";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,10 @@ namespace Borepin.PageModel
|
|||||||
|
|
||||||
CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.State.free;
|
CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.State.free;
|
||||||
|
|
||||||
if (GiveBack == null)
|
//if (GiveBack == null)
|
||||||
{
|
//{
|
||||||
GiveBack = await MachineItem.Instance.GetGiveBack();
|
// GiveBack = await MachineItem.Instance.GetGiveBack();
|
||||||
}
|
//}
|
||||||
|
|
||||||
CanGiveBack = GiveBack != null;
|
CanGiveBack = GiveBack != null;
|
||||||
|
|
||||||
|
@ -3,20 +3,28 @@ using Newtonsoft.Json;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Essentials;
|
|
||||||
|
|
||||||
namespace Borepin.Service.Connections
|
namespace Borepin.Service.Connections
|
||||||
{
|
{
|
||||||
public class ConnectionService : IConnectionService
|
public class ConnectionService : IConnectionService
|
||||||
{
|
{
|
||||||
|
#region Private Properties
|
||||||
|
private readonly IPreferenceService _PreferenceService;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public ConnectionService(IPreferenceService preferenceService)
|
||||||
|
{
|
||||||
|
_PreferenceService = preferenceService;
|
||||||
|
}
|
||||||
|
|
||||||
public Task<List<Connection>> GetConnectionList()
|
public Task<List<Connection>> GetConnectionList()
|
||||||
{
|
{
|
||||||
return Task.FromResult(JsonConvert.DeserializeObject<List<Connection>>(Preferences.Get("connection_list", "[]")));
|
return Task.FromResult(JsonConvert.DeserializeObject<List<Connection>>(_PreferenceService.Get("connection_list", "[]")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> AddConnection(Connection connection)
|
public Task<bool> AddConnection(Connection connection)
|
||||||
{
|
{
|
||||||
List<Connection> connection_list = JsonConvert.DeserializeObject<List<Connection>>(Preferences.Get("connection_list", "[]"));
|
List<Connection> connection_list = JsonConvert.DeserializeObject<List<Connection>>(_PreferenceService.Get("connection_list", "[]"));
|
||||||
|
|
||||||
if(connection_list.Contains(connection))
|
if(connection_list.Contains(connection))
|
||||||
{
|
{
|
||||||
@ -25,14 +33,14 @@ namespace Borepin.Service.Connections
|
|||||||
|
|
||||||
connection_list.Add(connection);
|
connection_list.Add(connection);
|
||||||
|
|
||||||
Preferences.Set("connection_list", JsonConvert.SerializeObject(connection_list));
|
_PreferenceService.Set("connection_list", JsonConvert.SerializeObject(connection_list));
|
||||||
|
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> RemoveConnection(Connection connection)
|
public Task<bool> RemoveConnection(Connection connection)
|
||||||
{
|
{
|
||||||
List<Connection> connection_list = JsonConvert.DeserializeObject<List<Connection>>(Preferences.Get("connection_list", "[]"));
|
List<Connection> connection_list = JsonConvert.DeserializeObject<List<Connection>>(_PreferenceService.Get("connection_list", "[]"));
|
||||||
|
|
||||||
if (!connection_list.Contains(connection))
|
if (!connection_list.Contains(connection))
|
||||||
{
|
{
|
||||||
@ -41,14 +49,14 @@ namespace Borepin.Service.Connections
|
|||||||
|
|
||||||
connection_list.RemoveAll(x => x.Equals(connection));
|
connection_list.RemoveAll(x => x.Equals(connection));
|
||||||
|
|
||||||
Preferences.Set("connection_list", JsonConvert.SerializeObject(connection_list));
|
_PreferenceService.Set("connection_list", JsonConvert.SerializeObject(connection_list));
|
||||||
|
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<bool> LogConnect(Connection connection)
|
public Task<bool> LogConnect(Connection connection)
|
||||||
{
|
{
|
||||||
List<Connection> connection_list = JsonConvert.DeserializeObject<List<Connection>>(Preferences.Get("connection_list", "[]"));
|
List<Connection> connection_list = JsonConvert.DeserializeObject<List<Connection>>(_PreferenceService.Get("connection_list", "[]"));
|
||||||
|
|
||||||
if (!connection_list.Contains(connection))
|
if (!connection_list.Contains(connection))
|
||||||
{
|
{
|
||||||
@ -60,7 +68,7 @@ namespace Borepin.Service.Connections
|
|||||||
connection_update.LastTime = DateTime.UtcNow;
|
connection_update.LastTime = DateTime.UtcNow;
|
||||||
connection_list[index] = connection_update;
|
connection_list[index] = connection_update;
|
||||||
|
|
||||||
Preferences.Set("connection_list", JsonConvert.SerializeObject(connection_list));
|
_PreferenceService.Set("connection_list", JsonConvert.SerializeObject(connection_list));
|
||||||
|
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
using Borepin.Model;
|
using Borepin.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Essentials;
|
|
||||||
|
|
||||||
namespace Borepin.Service.Credentials
|
namespace Borepin.Service.Credentials
|
||||||
{
|
{
|
||||||
public class CredentialService : ICredentialService
|
public class CredentialService : ICredentialService
|
||||||
{
|
{
|
||||||
|
#region Private Properties
|
||||||
|
private readonly ISecretService _SecretService;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
public CredentialService(ISecretService secretService)
|
||||||
|
{
|
||||||
|
_SecretService = secretService;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public async Task<string> GetPasswordAsync(Connection connection)
|
public async Task<string> GetPasswordAsync(Connection connection)
|
||||||
{
|
{
|
||||||
if (connection.AuthenticationTyp != AuthenticationTyp.PLAIN)
|
if (connection.AuthenticationTyp != AuthenticationTyp.PLAIN)
|
||||||
@ -14,19 +24,19 @@ namespace Borepin.Service.Credentials
|
|||||||
throw new ArgumentException("AuthenticationTyp is not PLAIN");
|
throw new ArgumentException("AuthenticationTyp is not PLAIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
return await SecureStorage.GetAsync(string.Format("bffh_password_{0}_{1}", connection.Address.ToString(), connection.Username));
|
return await _SecretService.GetAsync(string.Format("bffh_password_{0}_{1}", connection.Address.ToString(), connection.Username));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> AddCredentialsAsync(Connection connection, string password)
|
public async Task<bool> AddCredentialsAsync(Connection connection, string password)
|
||||||
{
|
{
|
||||||
await SecureStorage.SetAsync(string.Format("bffh_password_{0}_{1}", connection.Address.ToString(), connection.Username), password);
|
await _SecretService.SetAsync(string.Format("bffh_password_{0}_{1}", connection.Address.ToString(), connection.Username), password);
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> RemoveCredentialsAsync(Connection connection)
|
public async Task<bool> RemoveCredentialsAsync(Connection connection)
|
||||||
{
|
{
|
||||||
SecureStorage.Remove(string.Format("bffh_password_{0}_{1}", connection.Address.ToString(), connection.Username));
|
_SecretService.Remove(string.Format("bffh_password_{0}_{1}", connection.Address.ToString(), connection.Username));
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
15
Borepin/Borepin/Service/IPreferenceService.cs
Normal file
15
Borepin/Borepin/Service/IPreferenceService.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace Borepin.Service
|
||||||
|
{
|
||||||
|
public interface IPreferenceService
|
||||||
|
{
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
bool ContainsKey(string key);
|
||||||
|
|
||||||
|
string Get(string key, string defaultValue);
|
||||||
|
|
||||||
|
void Remove(string key);
|
||||||
|
|
||||||
|
void Set(string key, string value);
|
||||||
|
}
|
||||||
|
}
|
15
Borepin/Borepin/Service/ISecretService.cs
Normal file
15
Borepin/Borepin/Service/ISecretService.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Borepin.Service
|
||||||
|
{
|
||||||
|
public interface ISecretService
|
||||||
|
{
|
||||||
|
Task<string> GetAsync(string key);
|
||||||
|
|
||||||
|
bool Remove(string key);
|
||||||
|
|
||||||
|
void RemoveAll();
|
||||||
|
|
||||||
|
Task SetAsync(string key, string value);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user