lessieverchpmq
New Member
So I'm trying to XML serialize a \[code\]List<IObject>\[/code\] derrived from an interface, but the \[code\]IObjects\[/code\] are generic types... best resort to code:\[code\]public interface IOSCMethod{ string Name { get; } object Value { get; set; } Type Type { get; }}public class OSCMethod<T> : IOSCMethod{ public string Name { get; set; } public T Value { get; set; } public Type Type { get { return _type; } } protected string _name; protected Type _type; public OSCMethod() { } // Explicit implementation of IFormField.Value object IOSCMethod.Value { get { return this.Value; } set { this.Value = http://stackoverflow.com/questions/12460289/(T)value; } }}\[/code\]And I have a List of IOSCMethods:\[code\]List<IOSCMethod>\[/code\]of which I add objects to in the following way:\[code\] List<IOSCMethod> methodList = new List<IOSCMethod>(); methodList.Add(new OSCMethod<float>() { Name = "/1/button1", Value = http://stackoverflow.com/questions/12460289/0 }); methodList.Add(new OSCMethod<float[]>() { Name ="/1/array1", Value = http://stackoverflow.com/questions/12460289/new float[10] });\[/code\]And it's this \[code\]methodList\[/code\] which is what I'm trying to serialize. But everytime I try, either I get a "Can't serialize an interface" but when I make it (either the \[code\]IOSCMethod\[/code\] or the \[code\]OSCMethod<T>\[/code\] class) implement \[code\]IXmlSerializable\[/code\] I get the problem of "can't serialize an object with a parameterless constructor. but obviously I can't because it's an interface! lame pants.Any thoughts?