is it possible to access an exist serialization model from defined model and then append a Contracted but unknown subtype to it, subsequently use it for serialization ?
or do i need to explicitly create a new model ? i.e. in this case for ModuleTwoFoo
Update
var model = TypeModel.Create();
model[typeof(IFooChild)].AddSubType(2, typeof(ModuleTwoFooChild));
model.CompileInPlace();
RuntimeModel.Default[] // model[] is the access ... Doh !
my only complain if at all ... wish there was a way to access the original model then build on it rather than having regenerate the model again
As stated by marc "essentially what is required is cloned but unfrozen model"
public interface IFoo
{
int FooNumber { get; set; }
IList<IFooChild> Children { get; set; }
}
[ProtoContract, ProtoInclude(1, typeof(ModuleOneFooChild))]
public interface IFooChild
{
IFoo Foo { get; set; }
string Detail { get; set; }
}
[ProtoContract]
public class ModuleOneFoo : IFoo
{
[ProtoMember(1)]
public int FooNumber { get; set; }
[ProtoMember(2)]
public IList<IFooChild> Children { get; set; }
}
[ProtoContract]
public class ModuleOneFooChild : IFooChild
{
public IFoo Foo { get; set; }
[ProtoMember(1)]
public string Detail { get; set; }
}
[ProtoContract]
public class ModuleTwoFoo : IFoo
{
[ProtoMember(1)]
public int FooNumber { get; set; }
[ProtoMember(2)]
public IList<IFooChild> Children { get; set; }
}
[ProtoContract]
public class ModuleTwoFooChild : IFooChild
{
public IFoo Foo { get; set; }
[ProtoMember(1)]
public string Detail { get; set; }
}