xml - Serializing when class inherits list (of object) -


I have a booking class which handles a list (message) I was wondering how to serial this Message in the booking class is the property of 3 attributes, partners, transactions and versions,

There are many properties of booking in my message class,

Now when I want to serial New message z.partner = "company name" z.transaction = "booking" z.version as new bookmarking DM X In the form, use

  dim z = "1.0" x.MessageType = "c" x.CustomerNumber = "123" x.BookingReference = " 5845 "x.CustomerBookingReference =" 036,598 "x.OutwardRoute =" PEMROS "x.SailingDate =" 20,120,107 "z.Message = SaveAsXML (z)  
with

save below

xmlfunction code
  y.Serialize new xmlSerializer (val.GetType) as public shared function SaveAsXML (ByRef Val as + val.FileName) (objStreamWriter , Val) objStreamWriter.Close () return true dim: as in the form of booking) slow objStreamWriter as New StreamWriter ("\ ftptest \ new booking \ c" Shish Do cat  

Where is wrong?

My booking class is as follows:

  Public class booking: Inheritance list (Message) Private message as message property & Lt; XmlAttribute & gt; String as a public property partnership & lt; XmlAttribute & gt; String as public property transaction & lt; XmlAttribute & gt; Receive messages as public property as string Public Property Message version Send Receive Send message MessageProperty = (message as value) value End Set End Property  

Also Here is the XML created by the above code

   Here is my deserializing code  
  New as the new StreamReader (filepath) using objStreamReader in an effort to sample real "path where the file dim x new XmlSerializer (GetType (booking), new XmlRootAttribute (" real ")) samples = x.Deserialize (objStreamReader) use as end Form1.DataGridView1.DataSource = samples Please try the true catch pre-exception MessageBox.Show (as the former. Message) try  

you Class structure is confusing the serializer, if it is received from booking list, it is very understandable that it has message property type Message (because it's is already a message type). It becomes a self-reference, there are some other problems and I have made the changes and it is sorted properly:

  Booking of public class forms the form of string public property transactions as a public property partner. The string public property version string as the new property in the form of public properties XMsgs (XMS) class public class XMessage public property A string publication As the property a string as a string and class as public property B  

a) as public property message of the sick in VB It is advisable to type the property as the same name. So I used XMessage

b) where XMLAttribute of the correct use should be many IDE errors and XML is not required for serialization

c) per packet To handle more than one message, I have changed XMsgs to a list asset, it allows a booking dataset for many messages. If you want to book 1 message per second, there is no need for 2 sections and just make it a booking.

d) Get rid of the private property used as a backing field.

Test and serialized code:

New Bookings B as B Applications = "abcdef" B.transaction = "12345" Biwarsn = "1.00.1" Dim m As new Aksmsaf MA = "Fu" MB = "times" Biaksmjikaed (M) 'List Prop new Serialization as a .XmlSerializer (B.GetType) y.Serialize (SR, b) termination dim y: Companies use as using 'block new System.IO.StreamWriter ( "\ temp \ Booking.xml c") sr StreamWriter Using
to settle

Comments

Popular posts from this blog

c++ - ERROR: cannot open source file x11\xlib.h -

c - What are pthread cancelation points used for? -

c# - Show a huge number of data in DevExpress GridView -