XmlSerializer and interfaces
-
Does anyone know if there is a problem with using an interface type as the type in the XmlSerializer constructor?
-
Does anyone know if there is a problem with using an interface type as the type in the XmlSerializer constructor?
I doubt it will work... considering that interfaces don't include constructors, and the xmlserializer requires one.
-
Does anyone know if there is a problem with using an interface type as the type in the XmlSerializer constructor?
Hi, im not to sure what u are asking, but in the methods of my option library http://www.codeproject.com/useritems/OptionLib.asp mite see how to get around this, by breaking the class (interface) down into properties and serializing that. Hope this help :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D
-
Hi, im not to sure what u are asking, but in the methods of my option library http://www.codeproject.com/useritems/OptionLib.asp mite see how to get around this, by breaking the class (interface) down into properties and serializing that. Hope this help :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D
XmlSerializer will not allow typeof(IMyInterface) as its reflected type. Its understandable as XmlSerializer does not use properties but only actual members. I guess this makes sense under the presumption of using get/set value members as interpreted values (ie they are generated from some other value in the class). Uhoh - they expect me to be logical... whats that crap about. ie private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } }
-
XmlSerializer will not allow typeof(IMyInterface) as its reflected type. Its understandable as XmlSerializer does not use properties but only actual members. I guess this makes sense under the presumption of using get/set value members as interpreted values (ie they are generated from some other value in the class). Uhoh - they expect me to be logical... whats that crap about. ie private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } }
Cromwell wrote: private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } } What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. Just my 2 cents :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D
-
Cromwell wrote: private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } } What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. Just my 2 cents :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D
leppie wrote: I cannot see the purpose of a private property. I would use them to wrap other operations that need to be performed when setting the value. Pretty much the same reason you would use any property in the first place ;) James "And we are all men; apart from the females." - Colin Davies
-
Cromwell wrote: private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } } What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. Just my 2 cents :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D
leppie wrote: What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. 1) I was just showing that because an interface cannot define actual member variables only methods, it makes sense that you cannot use them for XmlSerializer. 2) Oh my lordy - really! Private properties are sooo useful. Often over used by lazy (vb6 uhum :P - no offense just hate it) developers, but none-the-less important.