だから私はList<IObject>
インターフェースから派生したものをXMLシリアライズしようとしていますが、IObjects
それらはジェネリック型です...コードに頼るのが最善です:
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 = (T)value; }
}
}
そして、IOSCMethods のリストがあります。
List<IOSCMethod>
次の方法でオブジェクトを追加します。
List<IOSCMethod> methodList = new List<IOSCMethod>();
methodList.Add(new OSCMethod<float>() { Name = "/1/button1", Value = 0 });
methodList.Add(new OSCMethod<float[]>() { Name = "/1/array1", Value = new float[10] });
そして、methodList
これが私が連載しようとしているものです。しかし、私が試みるたびに、「インターフェイスをシリアル化できません」というメッセージが表示されますが、それを (IOSCMethod
またはOSCMethod<T>
クラスのいずれかで) 実装するIXmlSerializable
と、「パラメーターなしのコンストラクターでオブジェクトをシリアル化できません」という問題が発生しますが、明らかに私はインターフェースだから無理!ラメパンツ。
何かご意見は?