Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Serialize this OBJECT!

Serialize this OBJECT!

Scheduled Pinned Locked Moved C#
helptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zaboboa
    wrote on last edited by
    #1

    Hi Can any one provide me with help on how to serialize this collection of objects? I was trying to put some tags, but I am not really getting anywhere. [XmlRoot ()] public class TableList { private ArrayList tableList; public TableList() { tableList = new ArrayList(); } [XmlArray("tables")] public MyTableItem[] Tables { get { MyTableItem[] tables = new MyTableItem [tableList.Count]; tableList.CopyTo(tables); return tables; } } public int AddTable(MyTableItem table) { return tableList.Add(table); } public class MyTableItem { TableInfo TableInfo = new TableInfo(); [XmlElement("name")] public string TableName = string.Empty; [XmlElement("id")] public string OasisID = string.Empty; [XmlElement("Info")] public Object TableInformation = new Object(); public MyTableItem () { } public MyTableItem (string Name, string OasisID) { this.TableName = Name; this.OasisID = OasisID; TableInformation = TableInfo.GetTableInformation(Name); } } public class TableInfo { public TableInfo () { } public Object GetTableInformation (string tableName) { if (tableName == "Table1") { Table1 tb1 = new Table1(); return tb1; } if (tableName == "Table2") { Table2 tb2 = new Table2(); return tb2; } return null; } } public class Table1 { [XmlAttribute()] public string Prop = "Hello"; public Table1() { } } public class Table2 { [XmlAttribute()] public string WhatIsThis = "Test string"; public Table2() { } } Thank you very much!

    Z 1 Reply Last reply
    0
    • Z zaboboa

      Hi Can any one provide me with help on how to serialize this collection of objects? I was trying to put some tags, but I am not really getting anywhere. [XmlRoot ()] public class TableList { private ArrayList tableList; public TableList() { tableList = new ArrayList(); } [XmlArray("tables")] public MyTableItem[] Tables { get { MyTableItem[] tables = new MyTableItem [tableList.Count]; tableList.CopyTo(tables); return tables; } } public int AddTable(MyTableItem table) { return tableList.Add(table); } public class MyTableItem { TableInfo TableInfo = new TableInfo(); [XmlElement("name")] public string TableName = string.Empty; [XmlElement("id")] public string OasisID = string.Empty; [XmlElement("Info")] public Object TableInformation = new Object(); public MyTableItem () { } public MyTableItem (string Name, string OasisID) { this.TableName = Name; this.OasisID = OasisID; TableInformation = TableInfo.GetTableInformation(Name); } } public class TableInfo { public TableInfo () { } public Object GetTableInformation (string tableName) { if (tableName == "Table1") { Table1 tb1 = new Table1(); return tb1; } if (tableName == "Table2") { Table2 tb2 = new Table2(); return tb2; } return null; } } public class Table1 { [XmlAttribute()] public string Prop = "Hello"; public Table1() { } } public class Table2 { [XmlAttribute()] public string WhatIsThis = "Test string"; public Table2() { } } Thank you very much!

      Z Offline
      Z Offline
      Zoltan Balazs
      wrote on last edited by
      #2

      A couple of posts down you were saying that you serialized an object. Did you read my response or you are just asking around without a clue? A couple of links for you: clickety[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups