Ejemplo n.º 1
0
        public void can_add_and_retrive_basic_class()
        {
            MicroMap.Initialize();
            MicroMap.Register <Interface1, Class1>();

            var instance = MicroMap.GetInstance <Interface1>();

            Assert.AreEqual(instance.GetType(), typeof(Class1));
        }
Ejemplo n.º 2
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            _commandBus = MicroMap.GetInstance <ICommandBus>();

            // Set the data context of the listbox control to the sample data
            DataContext = MicroMap.GetInstance <IMainViewModel>();
            Loaded     += MainPageLoaded;
        }
Ejemplo n.º 3
0
        public void can_build_up_single_depenancy()
        {
            MicroMap.Initialize();
            MicroMap.Register <Interface1, Class1>();
            MicroMap.Register <Interface2, Class2>();

            var instance = MicroMap.GetInstance <Interface2>();

            Assert.AreEqual(instance.GetType(), typeof(Class2));

            Assert.AreEqual(instance.Class1.GetType(), typeof(Class1));
        }
Ejemplo n.º 4
0
        public void can_add_and_retreive_from_func_definition()
        {
            MicroMap.Initialize();
            MicroMap.Register <Interface1>(x =>
            {
                var class1 = new Class1();
                return(class1);
            });

            var instance = MicroMap.GetInstance <Interface1>();

            Assert.AreEqual(instance.GetType(), typeof(Class1));
        }
Ejemplo n.º 5
0
        public void can_add_and_retrieve_static_class()
        {
            var staticClass = new Class1();

            MicroMap.Initialize();
            MicroMap.Register <Interface1>(staticClass);

            var instance  = MicroMap.GetInstance <Interface1>();
            var instance2 = MicroMap.GetInstance <Interface1>();

            Assert.AreEqual(instance, staticClass);
            Assert.AreEqual(instance2, staticClass);
        }
Ejemplo n.º 6
0
        public void builds_up_complex_dependancy()
        {
            MicroMap.Initialize();
            MicroMap.Register <Interface1, Class1>();
            MicroMap.Register <Interface2>(x => new Class2(x.GetInstance <Interface1>()));
            MicroMap.Register <Interface3, Class3>();

            var instance = MicroMap.GetInstance <Interface3>();

            Assert.AreEqual(instance.GetType(), typeof(Class3));

            Assert.AreEqual(instance.Class1.GetType(), typeof(Class1));
            Assert.AreEqual(instance.Class2.GetType(), typeof(Class2));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters
                //Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;
            }

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // setup container
            var state      = new ApplicationState();
            var commandBus = new CommandBus();

            var mainViewModel    = new MainViewModel();
            var addPageViewModel = new AddPageViewModel();

            _initializationAction = (IContainer x) =>
            {
                x.Register <ISettingsManager, SettingsManager>();
                x.Register <IStorageManager, StorageManager>();
                x.Register <IUIThreadInvoker, UIThreadInvoker>();
                x.Register <ICommandBus>(commandBus);
                x.Register <IApplicationState>(state);

                x.Register <INavigationServiceWrapper, NavigationServiceWrapper>();
                x.Register <IDialogService, DialogService>();
                x.Register <ITrialService, TrialService>();

                x.Register <ICommandHandler <ApplicationLoadedCommand>, ApplicationLoadedCommandHandler>();
                x.Register <ICommandHandler <MainPageLoadedCommand>, MainPageLoadedCommandHandler>();
                x.Register <ICommandHandler <AddNewShortCodeCommand>, AddNewShortCodeCommandHandler>();
                x.Register <ICommandHandler <EditShortCodeCommand>, EditShortCodeCommandHandler>();
                x.Register <ICommandHandler <SaveShortCodeCommand>, SaveShortCodeCommandHandler>();
                x.Register <ICommandHandler <DeleteShortCodeCommand>, DeleteShortCodeCommandHandler>();
                x.Register <ICommandHandler <SendSmsCommand>, SendSmsCommandHandler>();
                x.Register <ICommandHandler <DataLoadedMessage>, DataLoadedCommandHandler>();

                x.Register <IValidator <ShortCode>, ShortCodeValidator>();

                x.Register <IMainViewModel>(mainViewModel);
                x.Register <IAddPageViewModel>(addPageViewModel);
            };
            MicroMap.Initialize(_initializationAction);

            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <ApplicationLoadedCommand> >());
            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <MainPageLoadedCommand> >());
            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <AddNewShortCodeCommand> >());
            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <EditShortCodeCommand> >());
            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <SaveShortCodeCommand> >());
            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <DeleteShortCodeCommand> >());
            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <SendSmsCommand> >());
            commandBus.RegisterHandler(MicroMap.GetInstance <ICommandHandler <DataLoadedMessage> >());
        }
Ejemplo n.º 8
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            var commandBus = MicroMap.GetInstance <ICommandBus>();

            commandBus.PublishCommand(new ApplicationLoadedCommand());
        }
Ejemplo n.º 9
0
        private void SaveButtonClick(object sender, RoutedEventArgs e)
        {
            var commandBus = MicroMap.GetInstance <ICommandBus>();

            commandBus.PublishCommand(new SaveShortCodeCommand());
        }
Ejemplo n.º 10
0
 public AddPage()
 {
     InitializeComponent();
     DataContext = MicroMap.GetInstance <IAddPageViewModel>();
 }