Been banging my head on this for a while now
The problem I have is trying to add the IEquatable behaviour so my derived classes can use set operations Intersect of ILink etc.
At the moment I have...
public interface ILink
{
int Linkid { get; set; }
bool IsActive { get; set; }
}
and a bunch of derived classes like
public class Domain : ILink
{
public Domain(){}
}
public class User : ILink
{
public User (){}
}
so in order to do Intersection of List I thought I'd create an abstract class like so...
public abstract class AbstractLink : IEquatable<ILink>, ISerializable, ILink
{
public AbstractLink(){}
public AbstractLink(SerializationInfo info, StreamingContext ctxt)
{}
public virtual void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{}
}
however when I change my derived types from
public class DomainLink : ILink
{
}
to
public class DomainLink : AbstractLink
{
}
I get a SerializationException "Member 'Linkid' was not found." which is the 1st member it attempts to deserialize
BTW: this is Remoting hence the need for the custom Serialization - is there a way to compose these behaviours together?
Many thanks!
M
Your example code does not compile. You do not implement the ILink interface members.
The following code does work.
Each object that overrides AbstractLink requires a serialization constructor. Each subclass for AbstractLink also needs to be annotated with [Serializable]. If you add extra properties to the domain objects you will also need to implement GetObjectData() for the extra properties.