private void WriteValue(BinaryWriter writer, ControllerSerializationContext ctx, object value) { IControllerValueSerializer serializer = _serializers.FirstOrDefault(s => s.IsSupported(ctx)); if (serializer == null) { throw new NotImplementedException($"The specified type '{ctx.Type.FullName}' is not supported or implemented."); } serializer.Serialize(writer, ctx, value); }
/// <inheritdoc /> public object Deserialize(BinaryReader reader, ControllerSerializationContext serializationContext) { Type underlyingType = Nullable.GetUnderlyingType(serializationContext.Type); var innerContext = new ControllerSerializationContext(underlyingType, serializationContext.Controller); IControllerValueSerializer serializer = _serializers.FirstOrDefault(s => s.IsSupported(innerContext)); return(serializer != null ? serializer.Deserialize(reader, serializationContext) : reader.ReadStruct(underlyingType)); }
private object ReadValue(BinaryReader reader, ControllerSerializationContext ctx) { IControllerValueSerializer serializer = _serializers.FirstOrDefault(s => s.IsSupported(ctx)); object result = serializer?.Deserialize(reader, ctx); if (result == null) { throw new NotImplementedException($"The specified type '{ctx.Type.FullName}' is not supported or implemented."); } return(result); }