{"id":5241,"date":"2014-03-30T20:00:11","date_gmt":"2014-03-30T20:00:11","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/custom-object-collection-serialization-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:00:11","modified_gmt":"2014-03-30T20:00:11","slug":"custom-object-collection-serialization-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/custom-object-collection-serialization-collection-of-common-programming-errors\/","title":{"rendered":"Custom Object collection Serialization-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m attempting to Serialize my custom collection UserDataCollection, made out of UserData objects. I wondered when implementing Serialization, does the actual object (UserData) also need have the attribute [Serializable] and inherit from the ISerializable interface?<\/p>\n<p>I want to serialize each object (UserData) in the collection, all it&#8217;s properties and variables.<\/p>\n<p>I have this at the moment:<\/p>\n<pre><code>public class UserData : IEquatable, IUser\n{\n\/\/\/ some properties methods\n}\n\n    [Serializable()]\n    class UserDataCollection : IEnumerable, ISerializable\n    {\n        static List Collection = new List();\n        IUser current;\n\n        #region Properties\n        public UserData Current\n        {\n            get \n            { \n                return (UserData)current; \n            }\n\n            set\n            {\n                current = value;\n            }\n        }\n        #endregion\n\n\n        #region Constructors\n        public UserDataCollection( IUser userdata )\n        {\n            this.current = userdata;\n        }\n\n        \/\/\/ \n        \/\/\/ Deserialization Constructor\n        \/\/\/ \n        \/\/\/ This object holds a name-value pair for the             properties to be serialized\n        \/\/\/ \n        public UserDataCollection(SerializationInfo serializationInfo, StreamingContext ctxt)\n        {\n            Current = (UserData)serializationInfo.GetValue(\"UserData\", typeof(UserData));<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m attempting to Serialize my custom collection UserDataCollection, made out of UserData objects. I wondered when implementing Serialization, does the actual object (UserData) also need have the attribute [Serializable] and inherit from the ISerializable interface? I want to serialize each object (UserData) in the collection, all it&#8217;s properties and variables. I have this at the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5241","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5241"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5241\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}