tailieunhanh - Ivor Horton’s BeginningVisual C++ 2008 phần 9

Vấn đề là các hệ thống phối hợp mà bạn đang sử dụng và số nhiều đó là cố ý. Bạn đã thực sự được sử dụng hai hệ thống phối hợp trong tất cả các ví dụ cho đến nay, mặc dù bạn không có thể nhận thấy. Như bạn đã thấy trong chương trước, khi bạn gọi một chức năng chẳng hạn như LineTo (), | Chapter 18 Storing and Printing Documents Figure 18-9 Serialization and Printing in CLR Sketcher Serialization is the process of writing objects to a stream and deserialization is the reverse reconstructing objects from a stream. The .NET Framework offers several different ways to serialize and deserialize your C CLI class objects. XML serialization serializes objects into an XML stream that conforms to a particular XML schema. You can also serialize objects into XML streams that conform to the Simple Object Access Protocol SOAP specification and this is referred to as SOAP serialization. A discussion of XML and SOAP is beyond the scope of this book not because it s difficult it isn t but because to cover it adequately requires more pages than I can possibly include in this book. I ll therefore show you how to use the third and perhaps simplest form of serialization provided by the .NET Framework binary serialization. You ll also investigate how you can print sketches from CLR Sketcher. With the help given by the Form Designer this is going to be easy. Understanding Binary Serialization Before you get into the specifics of serializing a sketch let s get an overview of what s involved in binary serialization of your class objects. For binary serialization of your class objects to be possible you have 1078 Chapter 18 Storing and Printing Documents to make your classes serializable. You can make a ref class or value class serializable by marking it with the Serializable attribute like this Serializable public ref class MyClass Class definition. Of course in practice there may be a little more to it. For serialization to work with MyClass all the class fields must be serializable too and often there are fields that are not serializable by default or fields that it does not make sense to serialize because the data stored will not be valid when it is deserialized or fields that you just don t want serialized for security reasons. In this case special measures are .

crossorigin="anonymous">
Đã 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.