NET Domain-Driven Design with C#P roblem – Design – Solution phần 2

, vì nó không thực sự là một phần của logic miền, nhưng nó là cung cấp chức năng cần thiết để mô hình miền. Dưới đây là mã cho lớp này: | Chapter 2 Designing the Layered Architecture Layered Supertype The layered supertype I will use is an abstract class named EntityBase with the intention that all Entity classes in the domain model will need to inherit from this class to gain their identity. This class will live in the project as it is not really part of the domain logic but it is providing necessary functionality to the domain model. Here is the code for this class using System namespace public abstract class EntityBase private object key summary Default Constructor. summary protected EntityBase this null summary Overloaded constructor. summary param name key An see cref that represents the primary identifier value for the class. param protected EntityBase object key key summary An see cref that represents the primary identifier value for the class. summary public object Key get return The first part of the class contains a default constructor and an overloaded constructor that allow a key value to be passed in. The key that was passed in is also exposed as a read-only property. Currently I am leaving the Key property s type as a because I am not really sure yet if the keys to the entities will be Guids Integers an so on. Also some key data types on entity objects may be different from others and so for right now this gives me the most flexibility. 20 Chapter 2 Designing the Layered Architecture The next part of the code implements all of the necessary equality tests to determine whether two entity objects are equal to each other. These come in very handy later when comparing entity values in collections trying to find matches and so forth. region Equality Tests III summary III Determines whether the specified entity is equal to the III current instance. III Isummary III param name entity An see cref I that III will be compared to the current instance. Iparam III .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.