protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // init stubs var fakeExplorer = new Mock<Explorer>(); fakeExplorer.SetupAllProperties(); var fakeMailItem = new Mock<MailItem>(); fakeMailItem.SetupAllProperties(); fakeMailItem.Object.Subject = "test subj"; fakeMailItem.Object.Body = "test body"; var atts = new Mock<Attachments>(); atts.Setup(a => a.GetEnumerator()).Returns(ProductList); fakeMailItem.SetupGet(m => m.Attachments).Returns(atts.Object); var _container = new SimpleContainer() .RegisterSingle(fakeExplorer) .Register<IView>(container => new NewWorkItem()) .Register<AppViewModel>(container => new AppViewModel()) .Register<IPresenter>(container => new Presenter { View = container.Create<IView>(), ViewModel = container.Create<AppViewModel>() }); var form = _container.Create<IPresenter>(); form.Initialize(fakeMailItem.Object); }
/// <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() { container.Register <IQuoteLoader, QuoteLoader>(); container.Create <QuoteManager>(); ServiceLocator.Instance.Add <ITextToSpeech, TextToSpeechService>(); this.InitializeComponent(); this.Suspending += OnSuspending; }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions) { container.Register <IQuoteLoader, QuoteLoader>(); container.Register <ITextToSpeech, TextToSpeechService>(); container.Create <QuoteManager>(); global::Xamarin.Forms.Forms.Init(); LoadApplication(new App()); return(base.FinishedLaunching(uiApplication, launchOptions)); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); container.Register <IQuoteLoader, QuoteLoader>(); container.Register <ITextToSpeech, TextToSpeechService>(); container.Create <QuoteManager>(); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions) { container.Register <IQuoteLoader, QuoteLoader>(); container.Register <ITextToSpeech, TextToSpeechService>(); container.Create <QuoteManager>(); ServiceLocator.Instance.Add <ITextToSpeech, TextToSpeechService>(); global::Xamarin.Forms.Forms.Init(); LoadApplication(new App()); //var quoteLoader = new QuoteLoader(); //GreatQuotesViewModel = new MainViewModel(() => quoteLoader.Save(GreatQuotesViewModel.Quotes)) { // Quotes = new ObservableCollection<GreatQuoteViewModel>(quoteLoader.Load()) //}; //global::Xamarin.Forms.Forms.Init(); //var app = new App(GreatQuotesViewModel); //LoadApplication(app); return(base.FinishedLaunching(uiApplication, launchOptions)); }