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