Thinking in C# phần 10

GDI + cung cấp một loạt các bản vẽ, phối hợp, và các công cụ đo lường khác nhau, từ đơn giản vẽ dòng dốc phức tạp đầy. Ưu điểm của việc này là hầu như bất kỳ loại giao diện có thể được tạo ra bằng cách sử dụng GDI + (3D giao diện yêu cầu DirectX, mà sẽ được đề cập sau). Điểm bất lợi là GDI + là không quốc tịch, bạn phải viết mã có khả năng tái-vẽ GDI + toàn bộ giao diện bất cứ lúc nào. . | The property is associated with the XmlIgnore attribute which specifies that the XmlSerializer not include the property in the XML document. Deserializing XML The method converts an XML document into an object of the appropriate type c17 Compile with csc reference Demonstrates XML Deserialization using System using using public class CarFromFile public static void Main XmlSerializer xs new XmlSerializer typeof Car FileStream str new FileStream Car c Car str 0 1 2 3 4 This example requires a reference to the Car and other domain objects defined in the CarStructure example but so long as the public properties of the object suffice to put it into a viable state the XmlSerializer can both write and read objects to any kind of Stream. Can t serialize cycles This is a perfectly legitimate object-oriented relationship Figure 17-2 Cyclical relationships can be hard to express in XML Chapter 17 XML 789 In this relationship a Yang contains a reference to a Yin and a Yin to a Yang. It is possible for both objects to contain references to each other the data structure may have a cycle. XML does not use references to relate objects it uses containment. One object contains another which in turn contains its subobjects. There are no references native to XML. If the XmlSerializer detects a cycle it throws an InvalidOperationException as this example demonstrates c17 Throws an exception due to cyclical reference using System using public class Yin Yang yang public Yang Yang get return yang set yang value public Yin public class Yang Yin yin public Yin Yin get return yin set yin value public Yang public static void Main Yin yin new Yin Yang yang new Yang Set up cycle yang .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
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.