コード例 #1
0
ファイル: BusinessLogic.cs プロジェクト: sdepouw/learning-ioc
        public void Validate()
        {
            List <string> widgets = widgetRepository.FetchWidgets();

            if (!widgets.Any())
            {
                throw new BusinessLogicValidationFailedException();
            }
            Console.WriteLine("Business Logic has validated the wdigets.");
        }
コード例 #2
0
        public ActionResult About()
        {
            // Let's make a payment when the user visits the about page!
            string myWidget = widgetRepository.FetchWidgets().Last();

            paymentService.MakePaymentForWidget(myWidget);

            ViewBag.Message = string.Format("Payment made for the '{0}' widget!", myWidget);

            return(View());
        }
コード例 #3
0
        public void Run()
        {
            businessLogic.Validate();

            List <string> widgets = widgetRepository.FetchWidgets();

            gizmoRepository.Get();
            gizmoRepository.Get();
            gizmoRepository.Get();

            paymentService.MakePaymentForWidget(widgets.First());
        }
コード例 #4
0
 public List <string> FetchWidgets()
 {
     if (_widgets == null)
     {
         _widgets = widgetRepository.FetchWidgets();
     }
     else
     {
         Console.WriteLine("Using cached widgets!");
     }
     return(_widgets);
 }