/// <summary> /// Sets Inversion of Control. /// </summary> private void SetIoC() { var resolverContainer = new SimpleContainer(); var app = new XFormsAppWin(); app.Init(this); var documents = app.AppDataDirectory; var pathToDatabase = Path.Combine(documents, "xforms.db"); resolverContainer .Register <IDevice>(t => WindowsDevice.CurrentDevice) .Register <IDisplay>(t => new Display()) //.Register<IFontManager>(t => new FontManager(t.Resolve<IDisplay>())) //.Register<IEmailService, EmailService>() //.Register<IMediaPicker, MediaPicker>() .Register <IJsonSerializer, JsonSerializer>() .Register <ITextToSpeechService, TextToSpeechService>() .Register <IDependencyContainer>(t => resolverContainer) .Register <XFormsAppWin>(app) .Register <IXFormsApp>(app) .Register <ISecureStorage, SecureStorage>() //.Register<ICacheProvider>( // t => new SQLiteSimpleCache(new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8(), // new SQLite.Net.SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>())) ; Resolver.SetResolver(resolverContainer.GetResolver()); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { InitializeComponent(); var xFormsApp = new XFormsAppWin(); xFormsApp.Init(this); Suspending += OnSuspending; }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Xamarin.Forms.Forms.Init(e); var app = new XFormsAppWin(); app.Init(this); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Sets Inversion of Control. /// </summary> private void SetIoC() { var resolverContainer = new SimpleContainer(); var app = new XFormsAppWin(); app.Init(this); //var documents = app.AppDataDirectory; //var pathToDatabase = Path.Combine(documents, "xforms.db"); resolverContainer //.Register<IDevice>(t => WindowsPhoneDevice.CurrentDevice) .Register<IDisplay>(t => new Display()) //.Register<IFontManager>(t => new FontManager(t.Resolve<IDisplay>())) //.Register<IEmailService, EmailService>() //.Register<IMediaPicker, MediaPicker>() .Register<IJsonSerializer, JsonSerializer>() //.Register<ITextToSpeechService, TextToSpeechService>() .Register<IDependencyContainer>(t => resolverContainer) .Register<XFormsAppWin>(app) .Register<IXFormsApp>(app) //.Register<ISecureStorage, SecureStorage>() //.Register<ISimpleCache>( // t => new SQLiteSimpleCache(new SQLite.Net.Platform.WindowsPhone8.SQLitePlatformWP8(), // new SQLite.Net.SQLiteConnectionString(pathToDatabase, true), t.Resolve<IJsonSerializer>())) ; Resolver.SetResolver(resolverContainer.GetResolver()); }