Thinking in C# phần 10
➤ Gửi thông báo lỗi ⚠️ Báo cáo tài liệu vi phạmNội dung chi tiết: Thinking in C# phần 10
Thinking in C# phần 10
The Model.Horsepower property is associated with the [Xmllgnore] attribute, which specifies that the XmlSerializer not include the property in the XML Thinking in C# phần 10 L document,Deserializing XMLThe XndSerializer.Deserialize() method converts an XML document into an object of the appropriate type://:cl7:CarFromFile.es//Compile with://CSC /reference:Carstructure?.exe CarFromFile.es//Demonstrates XML Deserializationusing System;using System.10;using System.Xml.Seri Thinking in C# phần 10 alization;public class CarFromFile {public static void Main()(xmlse.rializer xs new xmlserializer(typeof(Car));Filestream str -new Filestream("car.xmThinking in C# phần 10
l", FileMode.Open) ;Car c (Car) xs.Deserialize (str);str.Close ();Console.WriteLme("{9} (1; {?}, {3} {4)"rc.Model.Year, c.Model.Maker, c.Model.Make,cThe Model.Horsepower property is associated with the [Xmllgnore] attribute, which specifies that the XmlSerializer not include the property in the XML Thinking in C# phần 10 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 cyclesThis is a perfectly legitimate object-oriented relationship:YangYin—11—Figure 17-2: Cyclical relationships can be ha Thinking in C# phần 10 rd to express 111 XMLChapter 17: XML 789In this relationship, a Yang contains a reference to a Yin and a Yin to a Yang It is possible for both objectsThinking in C# phần 10
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 objeThe Model.Horsepower property is associated with the [Xmllgnore] attribute, which specifies that the XmlSerializer not include the property in the XML Thinking in C# phần 10 InvalidOperationException, as this example demonstrates://:C17:YlnYang.cs//Throws an exception due to cyclical reference using System;using System.Xml.Serialization;public class Yin {Yang yang;public Yang Yang! Thinking in C# phần 10 The Model.Horsepower property is associated with the [Xmllgnore] attribute, which specifies that the XmlSerializer not include the property in the XMLGọi ngay
Chat zalo
Facebook