From 0baa07daa28310a18fcf2017db0ce42a541b33c6 Mon Sep 17 00:00:00 2001 From: kspearrin Date: Thu, 20 Sep 2018 13:18:30 -0400 Subject: [PATCH] load ioc and stuff --- .../CredentialProviderViewController.cs | 87 ++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 431ca03ba..ec1a57ab3 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -1,20 +1,38 @@ using AuthenticationServices; +using Bit.App.Abstractions; +using Bit.App.Repositories; +using Bit.App.Resources; +using Bit.App.Services; +using Bit.iOS.Autofill.Models; +using Bit.iOS.Core.Services; using Foundation; +using Plugin.Connectivity; +using Plugin.Fingerprint; +using Plugin.Settings.Abstractions; +using SimpleInjector; using System; using UIKit; - +using XLabs.Ioc; +using XLabs.Ioc.SimpleInjectorContainer; + namespace Bit.iOS.Autofill { public partial class CredentialProviderViewController : ASCredentialProviderViewController { + private Context _context = new Context(); + public CredentialProviderViewController (IntPtr handle) : base (handle) { } public override void ViewDidLoad() - { - System.Diagnostics.Debug.WriteLine("AUTOFILL view did load"); + { + SetIoc(); + SetCulture(); base.ViewDidLoad(); + _context.ExtContext = ExtensionContext; + + // TODO: HockeyApp } public override void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers) @@ -36,6 +54,69 @@ namespace Bit.iOS.Autofill public override void PrepareInterfaceForExtensionConfiguration() { base.PrepareInterfaceForExtensionConfiguration(); + } + + private void SetIoc() + { + var container = new Container(); + + // Services + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + + // Repositories + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + container.RegisterSingleton(); + + // Other + container.RegisterSingleton(CrossConnectivity.Current); + container.RegisterSingleton(CrossFingerprint.Current); + + var settings = new Settings("group.com.8bit.bitwarden"); + container.RegisterSingleton(settings); + + Resolver.ResetResolver(new SimpleInjectorResolver(container)); + } + + private void SetCulture() + { + var localizeService = Resolver.Resolve(); + var ci = localizeService.GetCurrentCultureInfo(); + AppResources.Culture = ci; + localizeService.SetLocale(ci); } } } \ No newline at end of file