Don't try to send unserializable value types over the wire with VV.

This commit is contained in:
Pieter-Jan Briers
2019-07-26 23:36:24 +02:00
parent c5ef7fd134
commit 9355938f6a
6 changed files with 21 additions and 7 deletions

View File

@@ -6,8 +6,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Robust.Shared.Maths;
namespace Robust.Shared.Serialization
{
@@ -18,6 +16,7 @@ namespace Robust.Shared.Serialization
private readonly IReflectionManager reflectionManager;
#pragma warning restore 649
private Serializer Serializer;
private HashSet<Type> SerializableTypes;
public void Initialize()
{
@@ -34,6 +33,7 @@ namespace Robust.Shared.Serialization
var settings = new Settings();
Serializer = new Serializer(types, settings);
SerializableTypes = new HashSet<Type>(Serializer.GetTypeMap().Keys);
}
public void Serialize(Stream stream, object toSerialize)
@@ -50,5 +50,10 @@ namespace Robust.Shared.Serialization
{
return Serializer.Deserialize(stream);
}
public bool CanSerialize(Type type)
{
return SerializableTypes.Contains(type);
}
}
}