mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Prototype of serialization for types that don't exist in the client domain
This commit is contained in:
@@ -41,12 +41,21 @@ internal class BsonFormatter : IFormatter
|
||||
{
|
||||
CloseInput = false
|
||||
};
|
||||
|
||||
// If the type is accessible from the current domain,
|
||||
// create an instance of it.
|
||||
var typeName = _serializer.Deserialize<string>(reader);
|
||||
var type = Type.GetType(typeName);
|
||||
if (type != null)
|
||||
return _serializer.Deserialize(reader, type);
|
||||
|
||||
return _serializer.Deserialize(reader);
|
||||
}
|
||||
|
||||
public void Serialize(Stream serializationStream, object graph)
|
||||
{
|
||||
using BsonDataWriter writer = new(serializationStream);
|
||||
_serializer.Serialize(writer, graph?.GetType().FullName);
|
||||
_serializer.Serialize(writer, graph);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user