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. Desktop/Mobile Serialization

Desktop/Mobile Serialization

Scheduled Pinned Locked Moved C#
csharpdatabasexmljsonhelp
1 Posts 1 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.
  • 8 Offline
    8 Offline
    8thWonder
    wrote on last edited by
    #1

    Hi, I have a class hierarchy of objects representing typical stuff like employees, users, addresses and so on. I've defined the relationships, created a database and now want to add serialization. The top-most class is an abstract one, kind of like CObject I suppose and my objects may exist on a desktop or mobile platform. I started to implement custom serialization but the Compact Framework doesn't support it so now I have to write my own stuff. What I'm looking for is some ideas as to how best to implement serialization for my system. Typically, each object will need to be serialized to/from my database and to/from a web service so I'm guessing I just need to write some methods to serialize to XML and/or to a MemoryStream object. OK, assuming that's the way to implement the actual serialization, how best to define it within my hierarchy? I was thinking of two virtual methods, toXML() and fromXML() defined withing my top-most class and an abstract method called getObjectData() which all descendents *must* implement.

    toXML();
    toMS();
    getObjectData();

    Within toXML() and toMS(), there's a call to getObjectData() which gets the object data ready to be formatted into a MemoryStream object or XML. Each object would also implement a constructor accepting an XML or MemoryStream object but I'm very new to C# so I don't know if there's a way of forcing derived classes to implement these constructors or whether I "should" or not. What do you think? Any help much appreciated including book/article suggestions :)

    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