コード例 #1
0
        static void Main(string[] args)
        {
            IPurchaseReportFactory reportFactory = new PurchaseReportFactory();

            ViewLocator viewLocator = new ViewLocator();

            viewLocator.RegisterService(Selector <DepositResult>, obj => new DepositView((DepositResult)obj));
            viewLocator.RegisterService(Selector <LoginFailed>, obj => new LoginFailedView((LoginFailed)obj));
            viewLocator.RegisterService(Selector <UserLoggedIn>, obj => new UserLoggedInView((UserLoggedIn)obj));
            viewLocator.RegisterService(Selector <UserLoggedOut>, obj => new UserLoggedOutView((UserLoggedOut)obj));
            viewLocator.RegisterService(Selector <UserRegistered>, obj => new UserRegisteredView((UserRegistered)obj));

            viewLocator.RegisterService(PurchaseSelector <FailedPurchase>, obj => new FailedPurchaseView());
            viewLocator.RegisterService(PurchaseSelector <NotEnoughMoney>, obj => new NotEnoughMoneyView(Cast <NotEnoughMoney>(obj)));
            viewLocator.RegisterService(PurchaseSelector <NotRegistered>, obj => new NotRegisteredView(Cast <NotRegistered>(obj)));
            viewLocator.RegisterService(PurchaseSelector <NotSignedIn>, obj => new NotSignedInView());
            viewLocator.RegisterService(PurchaseSelector <ProductNotFound>, obj => new ProductNotFoundView(Cast <ProductNotFound>(obj)));
            viewLocator.RegisterService(PurchaseSelector <Receipt>, obj => new ReceiptView(Cast <Receipt>(obj)));

            UserInterface ui =
                new UserInterface(
                    new ApplicationServices(
                        new DomainServices(
                            new UserRepository(),
                            new ProductRepository(),
                            reportFactory),
                        reportFactory),
                    viewLocator);

            while (ui.ReadCommand())
            {
                ui.ExecuteCommand();
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            IPurchaseReportFactory reportFactory = new PurchaseReportFactory();

            UserInterface ui =
                new UserInterface(
                    new ApplicationServices(
                        new DomainServices(
                            new UserRepository(),
                            new ProductRepository(),
                            reportFactory),
                        reportFactory));

            while (ui.ReadCommand())
            {
                ui.ExecuteCommand();
            }
        }
コード例 #3
0
        public static void Run()
        {
            var purchaseReportFactory = new PurchaseReportFactory();

            var           viewLocator = SetupViewLocator();
            UserInterface ui          =
                new UserInterface(
                    new ApplicationServices(
                        new DomainServices(
                            new UserRepository(),
                            new ProductRepository(),
                            purchaseReportFactory),
                        purchaseReportFactory), viewLocator);

            while (ui.ReadCommand())
            {
                ui.ExecuteCommand();
            }
        }