Consider the following. You have a class that you want to serialize using the XmlSerializer, which has a publicly accessible general method with a constraint type, where the type is in a different assembly:
using BarStuff;
namespace FooStuff {
public class Foo {
...
public T GetBar<TBar, T>( string key ) where TBar : Bar<T> {
...
}
}
}
You would not expect the XmlSerializer to even refer to methods, and this is usually not the case. The following both work fine:
private T GetBar<TBar, T>( string key ) where TBar : Bar<T> {
...
}
public Bar GetBar( string key ) {
...
}
In addition, if the Bar type is in the same assembly as Foo, the serializer will also be completely happy.
, Bar , , , , Bar, . , XmlInclude:
[XmlInclude(typeof(Bar))]
public class Foo {
public T GetBar<TBar, T>( string key ) where TBar : Bar<T> {
...
}
}
, Bar , , , -, , , , , ..!
, : XmlSerializer InvalidOperationException ,
: Microsoft