protected ModelBase(SerializationInfo info, StreamingContext context)
{
OnInitializing();
Initialize();
// Make sure this is not a first time call or custom call with null
if (info == null)
{
FinishInitializationAfterConstructionOrDeserialization();
}
else
{
_serializationInfo = info;
// Too bad we cannot put this in the BinarySerializer, but BinarySerialization works bottom => top. We
// do need the GraphId though, thus we are setting it here
var scopeName = SerializationContextHelper.GetSerializationReferenceManagerScopeName();
using (var scopeManager = ScopeManager<ReferenceManager>.GetScopeManager(scopeName))
{
var referenceManager = scopeManager.ScopeObject;
int? graphId = null;
try
{
// Binary
graphId = (int)info.GetValue("GraphId", typeof (int));
}
catch (Exception)
{
// Swallow
}
if (graphId.HasValue)
{
referenceManager.RegisterManually(graphId.Value, this);
}
}
}
OnInitialized();
}