Shorter JSON property names for nucache (#8204)

This commit is contained in:
Chad
2020-06-02 21:35:19 +12:00
committed by GitHub
parent 717bbf1e2e
commit a4274ba767
4 changed files with 94 additions and 45 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
using Newtonsoft.Json;
namespace Umbraco.Web.PublishedCache.NuCache.DataSource
@@ -8,21 +9,43 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
private string _culture;
private string _segment;
[JsonProperty("culture")]
[DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, PropertyName = "c")]
public string Culture
{
get => _culture;
set => _culture = value ?? throw new ArgumentNullException(nameof(value)); // TODO: or fallback to string.Empty? CANNOT be null
}
[JsonProperty("seg")]
[DefaultValue("")]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, PropertyName = "s")]
public string Segment
{
get => _segment;
set => _segment = value ?? throw new ArgumentNullException(nameof(value)); // TODO: or fallback to string.Empty? CANNOT be null
}
[JsonProperty("val")]
[JsonProperty("v")]
public object Value { get; set; }
//Legacy properties used to deserialize existing nucache db entries
[JsonProperty("culture")]
private string LegacyCulture
{
set => Culture = value;
}
[JsonProperty("seg")]
private string LegacySegment
{
set => Segment = value;
}
[JsonProperty("val")]
private object LegacyValue
{
set => Value = value;
}
}
}