I have 2 interfaces IA and IB.
public interface IA
{
IB InterfaceB { get; set; }
}
public interface IB
{
IA InterfaceA { get; set; }
void SetIA(IA value);
}
Each interfaces references the other.
I am trying to serialize ClassA as defined below.
[Serializable]
public class ClassA : IA
{
public IB InterfaceB { get; set; }
public ClassA()
{
// Call outside function to get Interface B
IB interfaceB = Program.GetInsanceForIB();
// Set IB to have A
interfaceB.SetIA(this);
}
}
[Serializable]
public class ClassB : IB
{
public IA InterfaceA { get; set; }
public void SetIA(IA value)
{
this.InterfaceA = value as ClassA;
}
}
I get an error when I try too serialize because the 2 properties are interfaces. I want to serialize the properties.
How would I get around this?
I need to have references in each interface to the other. And I need to be able to serialize the class back and forth.