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. Serialization

Serialization

Scheduled Pinned Locked Moved C#
tutorialcsharpjsonquestion
4 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.
  • V Offline
    V Offline
    vamsimohan21
    wrote on last edited by
    #1

    I have a list which is derived from CollectionBase, and it contains a list of User objects, which I want to Serialize. Is there anywhere where I can find how to decode it so that it recognizes what objects are held in my list? or an example in C# prefereably?

    Thanks In Advance

    K 1 Reply Last reply
    0
    • V vamsimohan21

      I have a list which is derived from CollectionBase, and it contains a list of User objects, which I want to Serialize. Is there anywhere where I can find how to decode it so that it recognizes what objects are held in my list? or an example in C# prefereably?

      Thanks In Advance

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #2

      As long as the User objects are serialiazable, the list will be. See http://msdn.microsoft.com/en-us/library/system.serializableattribute.aspx[^] and http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx[^]

      Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

      V 1 Reply Last reply
      0
      • K Keith Barrow

        As long as the User objects are serialiazable, the list will be. See http://msdn.microsoft.com/en-us/library/system.serializableattribute.aspx[^] and http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable.aspx[^]

        Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.

        V Offline
        V Offline
        vamsimohan21
        wrote on last edited by
        #3

        Sorry for my bad english, I am trying to do some thig like below Class A : Base { \\do somethig } Class B : Base { \\do somethig } Class Base { \\do something } Class Test : CustomCollection { \\do methods like Add,Remove..... } Class Main { Test Obj = new Test Obj.Add(A); Obj.Add(B); } Now I want to pass the Obj object from Main call to a webservice How can I achieve this?

        Thanks In Advance

        K 1 Reply Last reply
        0
        • V vamsimohan21

          Sorry for my bad english, I am trying to do some thig like below Class A : Base { \\do somethig } Class B : Base { \\do somethig } Class Base { \\do something } Class Test : CustomCollection { \\do methods like Add,Remove..... } Class Main { Test Obj = new Test Obj.Add(A); Obj.Add(B); } Now I want to pass the Obj object from Main call to a webservice How can I achieve this?

          Thanks In Advance

          K Offline
          K Offline
          Keith Barrow
          wrote on last edited by
          #4

          Services and object orientation do not play well together. I don't think it is desirable (I'm not sure it is even possible) to pass up a Test. The list / array needs to be of a known type, passing up a `Test` is certainly an option in WCF, but you need to register `A` and `B` as KnownTypes. What you have done gives off a "bad code smell", the class structure is perfectly fine from an OO point of view (I'm not sure of the purpose of ``Test or `CustomCollection` however), _but_ when calling services it is much better to use well defined types for making calls, and the onus is on the server to provide these types. Addtionally [if memory serves] custom collections / Lists are frowned upon in asmx services as they won't interop well with Java etc. The normal pattern with services is: 1. Define types that can be passed up and down the wire in web service calls. 2. Make method calls that use the defined types in step 1. 3. Use Wsdl.exe to generate a proxy class to communicate with the web (asmx) service You then will probably need to convert the types passed up and down the wire into your proper object model. **Dalek Dave:** There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter. **Pete o'Hanlon:** If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.``

          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