Adds migration for binary column on cmsContentNu

This commit is contained in:
Shannon
2020-07-03 15:41:25 +10:00
parent de67bdc2a2
commit 39625d94dd
9 changed files with 66 additions and 14 deletions

View File

@@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace Umbraco.Web.PublishedCache.NuCache.DataSource
{
internal class MsgPackContentNestedDataSerializer : IContentNestedDataSerializer
internal class MsgPackContentNestedDataSerializer : IContentNestedDataByteSerializer
{
private MessagePackSerializerOptions _options;
@@ -39,8 +39,6 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
return json;
}
// TODO: Instead of returning base64 it would be more ideal to avoid that translation entirely and just store/retrieve raw bytes
public ContentNestedData Deserialize(string data)
{
var bin = Convert.FromBase64String(data);
@@ -54,6 +52,10 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
return Convert.ToBase64String(bin);
}
public ContentNestedData DeserializeBytes(byte[] data) => MessagePackSerializer.Deserialize<ContentNestedData>(data, _options);
public byte[] SerializeBytes(ContentNestedData nestedData) => MessagePackSerializer.Serialize(nestedData, _options);
//private class ContentNestedDataResolver : IFormatterResolver
//{
// // GetFormatter<T>'s get cost should be minimized so use type cache.