TAILIEUCHUNG - Essential C# 3.0 FOR NET FRAMEWORK 3.5 PHẦN 9

Chương này bắt đầu với một cuộc thảo luận của đại biểu và sử dụng như tài liệu tham khảo các phương pháp hoặc callbacks. Nó giới thiệu một Quá tải các phương pháp bao bọc và cung cấp một số lượng giảmĐối với tất cả các P / Gọi phương pháp hỗ trợ GetLastError (), hãy chắc chắn | Attributes 651 Title Data Decrypt endregion Essentially the object is a collection of name value pairs. When serializing the GetOb-ject implementation calls AddValue . To reverse the process you call one of the Get members. In this case you encrypt and decrypt prior to serialization and deserialization respectively. Versioning the Serialization One more serialization point deserves mentioning versioning. Objects such as documents may be serialized using one version of an assembly and deserialized using a newer version sometimes the reverse. Without paying attention however version incompatibilities can easily be introduced sometimes unexpectedly. Consider the scenario shown in Table . Surprisingly even though all you did was to add a new field deserializing the original file throws a . This is because the formatter looks for data corresponding to the new field within the stream. Failure to locate such data throws an exception. To avoid this the framework and above includes a . When you require backward compatibility you must decorate serialized fields even private ones with OptionalFieldAttribute unless of course a latter version begins to require it . Unfortunately is not supported in the earlier framework version. Instead it is necessary to implement ISerializable just as you did for encryption saving and retrieving only the fields that are available. Assuming the addition of the Author field for example the implementation shown in 652 Chapter 17 Reflection and Attributes Table Deserialization of a New Version Throws an Exception Step Description Code 1 Define a class decorated with . 2 Add a field or two public or private of any serializable type. 3 .

TỪ KHÓA LIÊN QUAN
Đã 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.