A
Adam Benson
Hi,
A SerializationInfo gets passed to your constructor for manual
deserialization.
If your deserialization constructor did this :
protected BaseConfigData(SerializationInfo info, StreamingContext context)
{
ManualDeserialize(info, context);
}
protected virtual void ManualDeserialize(SerializationInfo info,
StreamingContext context)
{
channelName = info.GetString("BC_CN");
alias = info.GetString("BC_al");
// Rest of deserialization code ...
}
And you had the object serialized in a string and wanted to re-assert the
state.
Could you set up a SerializationInfo object and call ManualDeserialize?
Something like this :
SerializationInfo info;
StreamingContext context;
byte[] b;
MemoryStream ms;
b = System.Text.Encoding.UTF8.GetBytes( serialized_state );
ms = new MemoryStream(b);
ms.Position = 0;
// How do you set info up so that it reads from ms ??
// Because here it is created blank.
// If I could point it at ms and it read its state from there I could
deserialze ms into this object. Can that be done?
info = new SerializationInfo(this.GetType(),
new System.Runtime.Serialization.FormatterConverter());
context = new
StreamingContext(System.Runtime.Serialization.StreamingContextStates.All);
this.ManualDeserialize(info, context);
TVMIA,
- Adam.
==============================
(e-mail address removed)
A SerializationInfo gets passed to your constructor for manual
deserialization.
If your deserialization constructor did this :
protected BaseConfigData(SerializationInfo info, StreamingContext context)
{
ManualDeserialize(info, context);
}
protected virtual void ManualDeserialize(SerializationInfo info,
StreamingContext context)
{
channelName = info.GetString("BC_CN");
alias = info.GetString("BC_al");
// Rest of deserialization code ...
}
And you had the object serialized in a string and wanted to re-assert the
state.
Could you set up a SerializationInfo object and call ManualDeserialize?
Something like this :
SerializationInfo info;
StreamingContext context;
byte[] b;
MemoryStream ms;
b = System.Text.Encoding.UTF8.GetBytes( serialized_state );
ms = new MemoryStream(b);
ms.Position = 0;
// How do you set info up so that it reads from ms ??
// Because here it is created blank.
// If I could point it at ms and it read its state from there I could
deserialze ms into this object. Can that be done?
info = new SerializationInfo(this.GetType(),
new System.Runtime.Serialization.FormatterConverter());
context = new
StreamingContext(System.Runtime.Serialization.StreamingContextStates.All);
this.ManualDeserialize(info, context);
TVMIA,
- Adam.
==============================
(e-mail address removed)