TAILIEUCHUNG - Programming C# 4.0 phần 3

DynamicObject là một class đặc biệt trong namespace . Để có thể sử dụng được class DynamicObject, chúng ta không thể tạo ra các đối tượng trực tiếp từ class này mà bắt buộc chúng phải định nghĩa một class khác thừa kế từ class DynamicObject. | Summary So far we ve seen how to create classes to model relationships between instances of those classes through association composition and aggregation and to create relationships between classes by derivation. We also saw how virtual functions enable derived classes to replace selected aspects of a base class. We saw how to use protected and protected internal to control the visibility of members to derived classes. Then we saw how we can use either abstract classes and methods or interfaces to define public contracts for a class. Finally we looked at a means of examining the inheritance hierarchy by hand and verifying whether an object we are referencing through a base class is in fact an instance of a more derived class. In the next chapter we are going to look at some other techniques for code reuse and extensibility that don t rely on inheritance. 142 Chapter 4 Extensibility and Polymorphism CHAPTER 5 Composability and Extensibility with Delegates In the preceding two chapters we saw how to encapsulate behavior and information with classes. Using the concepts of association composition aggregation and derivation we modeled relationships between those classes and looked at some of the benefits of polymorphism along with the use and abuse of virtual functions and their implied contracts with derived classes. In this chapter we ll look at a functional rather than class-based approach to composition and extensibility and see how we can use this to implement some of the patterns that have previously required us to burn our one and only base class and override virtual functions and all with the added benefit of a looser coupling between classes. Let s start with another example. This time we want to build a system that processes incoming electronic documents prior to publication. We might want to do an automated spellcheck repaginate perform a machine translation for a foreign-language website or perform one of any other number of operations that our editors will

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.