TAILIEUCHUNG - Pro ASP.NET MVC Framework phần 3

Trên lý thuyết, mô hình này sẽ giúp những web designer chủ động thiết kế ra giao diện của ứng dụng mà không sợ ảnh hưởng đến những phần code xử lý bên dưới. Điều này dường như giống với ý tưởng tách rời giữa controller và view trong mô hình Model-View-Controller framework. | CHAPTER 4 SPORTSSTORE A REAL APPLICATION 99 configSections section name castle type -- . leave all the other section nodes as before . -- configSections Then directly inside the configuration node add a castle node configuration -- etc -- castle components components castle -- etc -- You can put the castle node immediately before . Finally instruct ASRNET MVC to use your new controller factory by calling SetControllerFactory inside the Application_Start handler in protected void Application_Start RegisterRoutes new WindsorControllerFactory At this point it s a good idea to check that everything still works as before when you run your application. Your new IoC container should be able to resolve ProductsController when ASRNET MVC requests it so the application should behave as if nothing s different. Using Your loC Container The whole point of bringing in an IoC container is that you can use it to eliminate hard-coded dependencies between components. Right now you re going to eliminate ProductsController s current hard-coded dependency on SqlProductsRepository which in turn means you ll eliminate the hard-coded connection string soon to be configured elsewhere . The advantages will soon become clear. When an IoC container instantiates an object . a controller class it inspects that type s list of constructor parameters . dependencies and tries to supply a suitable object for each one. So if you edit ProductsController adding a new constructor parameter as follows public class ProductsController Controller private IProductsRepository productsRepository public ProductsController IProductsRepository productsRepository productsRepository 100 CHAPTER 4 SPORTSSTORE A REAL APPLICATION public ViewResult List return View then the loC .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.