예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="device"></param>
        public App(IDevice device)
        {
            // Model
            kernel.Bind <IDevice>().ToConstant(device);

            kernel.Bind <DataService>().ToSelf().InSingletonScope();

            kernel.Bind <Calculator>().ToConstant(new Calculator(5));
            kernel.Bind <ApplicationState>().ToSelf().InSingletonScope();

            // View
            kernel.Bind <IMessenger>().To <Messenger>().InSingletonScope();

            // Navigator
            var navigator = new Navigator()
            {
                Factory  = new NinjectNavigatorFactory(kernel),
                Provider = new MessengerViewProvider(kernel.Get <IMessenger>())
            };

            navigator.AutoRegister(GetType().GetTypeInfo().Assembly);
            kernel.Bind <INavigator>().ToConstant(navigator);

            // MainPage
            MainPage = kernel.Get <MasterPage>();

            navigator.Forward(ViewId.Menu);
        }