Is there a way to force derived classes to implement serializable?
I have a base class which is serializable. When I distribute this class I need to ensure that any derived classes will have to implement serializable or throw an error. After looking through the documentation I added the [Serializable] attribute, will this do it?
[264 byte] By [
Lorren] at [2008-2-13]
Well is there a way NOT TO force your derive class to implement the Interface?
;)
I mean it is naturally in OO paradigm the derived class to implement the bare minimum of its base class functionality.
So I do not think you should take any extra considerations.
BTW why dont you try it for yourself.?
Ooops sorry I didnt grasp what exactly functionality you are ranning after.
I do not have any idea how to force Serialization but you can force disposing followinf the pattern:
[code]
public class A : IDisposable
{
public A()
{}
virtual public void Dispose()
{
Exception ex = new Exception("No Dispose implemented, blah blah ...");
throw ex;
}
}
public class B : A
{
public B()
{}
public void Dispose()
{
}
}
[/code]