Đang chuẩn bị liên kết để tải về tài liệu:
Programming C# 4.0 phần 3

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

DynamicObject là một class đặc biệt trong namespace System.Dynamic. Để 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

Đã 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.