Cleanup
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
/// <summary>
|
||||
/// The content item 1:M data that is serialized to JSON
|
||||
/// </summary>
|
||||
internal class ContentSerializedData
|
||||
internal class ContentNestedData
|
||||
{
|
||||
[JsonProperty("properties")]
|
||||
public Dictionary<string, PropertyData[]> PropertyData { get; set; }
|
||||
@@ -190,7 +190,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
}
|
||||
else
|
||||
{
|
||||
var deserialized = DeserializeData(dto.EditData);
|
||||
var nested = DeserializeNestedData(dto.EditData);
|
||||
|
||||
d = new ContentData
|
||||
{
|
||||
@@ -200,8 +200,8 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
VersionId = dto.VersionId,
|
||||
VersionDate = dto.EditVersionDate,
|
||||
WriterId = dto.EditWriterId,
|
||||
Properties = deserialized.PropertyData,
|
||||
CultureInfos = deserialized.CultureData
|
||||
Properties = nested.PropertyData,
|
||||
CultureInfos = nested.CultureData
|
||||
};
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
}
|
||||
else
|
||||
{
|
||||
var deserialized = DeserializeData(dto.PubData);
|
||||
var nested = DeserializeNestedData(dto.PubData);
|
||||
|
||||
p = new ContentData
|
||||
{
|
||||
@@ -225,8 +225,8 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
VersionId = dto.VersionId,
|
||||
VersionDate = dto.PubVersionDate,
|
||||
WriterId = dto.PubWriterId,
|
||||
Properties = deserialized.PropertyData,
|
||||
CultureInfos = deserialized.CultureData
|
||||
Properties = nested.PropertyData,
|
||||
CultureInfos = nested.CultureData
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
if (dto.EditData == null)
|
||||
throw new Exception("No data for media " + dto.Id);
|
||||
|
||||
var deserialized = DeserializeData(dto.EditData);
|
||||
var nested = DeserializeNestedData(dto.EditData);
|
||||
|
||||
var p = new ContentData
|
||||
{
|
||||
@@ -260,8 +260,8 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
VersionId = dto.VersionId,
|
||||
VersionDate = dto.EditVersionDate,
|
||||
WriterId = dto.CreatorId, // what-else?
|
||||
Properties = deserialized.PropertyData,
|
||||
CultureInfos = deserialized.CultureData
|
||||
Properties = nested.PropertyData,
|
||||
CultureInfos = nested.CultureData
|
||||
};
|
||||
|
||||
var n = new ContentNode(dto.Id, dto.Uid,
|
||||
@@ -277,7 +277,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
return s;
|
||||
}
|
||||
|
||||
private static ContentSerializedData DeserializeData(string data)
|
||||
private static ContentNestedData DeserializeNestedData(string data)
|
||||
{
|
||||
// by default JsonConvert will deserialize our numeric values as Int64
|
||||
// which is bad, because they were Int32 in the database - take care
|
||||
@@ -287,7 +287,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
Converters = new List<JsonConverter> { new ForceInt32Converter() }
|
||||
};
|
||||
|
||||
return JsonConvert.DeserializeObject<ContentSerializedData>(data, settings);
|
||||
return JsonConvert.DeserializeObject<ContentNestedData>(data, settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,10 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
var properties = new List<IPublishedProperty>();
|
||||
foreach (var propertyType in _contentNode.ContentType.PropertyTypes)
|
||||
{
|
||||
if (contentData.Properties.TryGetValue(propertyType.Alias, out var pdatas))
|
||||
{
|
||||
properties.Add(new Property(propertyType, this, pdatas, _publishedSnapshotAccessor));
|
||||
}
|
||||
else
|
||||
{
|
||||
//it doesn't exist in our serialized json but we should add it as an empty property so they are in sync
|
||||
properties.Add(new Property(propertyType, this, null, _publishedSnapshotAccessor));
|
||||
}
|
||||
// add one property per property type - this is required, for the indexing to work
|
||||
// if contentData supplies pdatas, use them, else use null
|
||||
contentData.Properties.TryGetValue(propertyType.Alias, out var pdatas); // else will be null
|
||||
properties.Add(new Property(propertyType, this, pdatas, _publishedSnapshotAccessor));
|
||||
}
|
||||
PropertiesArray = properties.ToArray();
|
||||
}
|
||||
@@ -265,9 +260,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
public override IPublishedProperty GetProperty(string alias)
|
||||
{
|
||||
var index = _contentNode.ContentType.GetPropertyIndex(alias);
|
||||
if (index < 0) return null;
|
||||
//fixme: This should not happen since we align the PropertiesArray with the property types in the ctor, if this does happen maybe we should throw a descriptive exception
|
||||
if (index >= PropertiesArray.Length) return null;
|
||||
if (index < 0) return null; // happens when 'alias' does not match a content type property alias
|
||||
if (index >= PropertiesArray.Length) // should never happen - properties array must be in sync with property type
|
||||
throw new IndexOutOfRangeException("Index points outside the properties array, which means the properties array is corrupt.");
|
||||
var property = PropertiesArray[index];
|
||||
return property;
|
||||
}
|
||||
|
||||
@@ -1179,9 +1179,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
//var propertyEditorResolver = PropertyEditorResolver.Current;
|
||||
//var dataTypeService = ApplicationContext.Current.Services.DataTypeService;
|
||||
|
||||
//the dictionary that will be serialized
|
||||
var data = new ContentSerializedData();
|
||||
|
||||
var propertyData = new Dictionary<string, PropertyData[]>();
|
||||
foreach (var prop in content.Properties)
|
||||
{
|
||||
@@ -1216,8 +1213,6 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
propertyData[prop.Alias] = pdatas.ToArray();
|
||||
}
|
||||
|
||||
data.PropertyData = propertyData;
|
||||
|
||||
var cultureData = new Dictionary<string, CultureVariation>();
|
||||
if (content.Names != null)
|
||||
{
|
||||
@@ -1233,7 +1228,12 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
}
|
||||
}
|
||||
|
||||
data.CultureData = cultureData;
|
||||
//the dictionary that will be serialized
|
||||
var nestedData = new ContentNestedData
|
||||
{
|
||||
PropertyData = propertyData,
|
||||
CultureData = cultureData
|
||||
};
|
||||
|
||||
var dto = new ContentNuDto
|
||||
{
|
||||
@@ -1243,7 +1243,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
// note that numeric values (which are Int32) are serialized without their
|
||||
// type (eg "value":1234) and JsonConvert by default deserializes them as Int64
|
||||
|
||||
Data = JsonConvert.SerializeObject(data)
|
||||
Data = JsonConvert.SerializeObject(nestedData)
|
||||
};
|
||||
|
||||
//Core.Composing.Current.Logger.Debug<PublishedSnapshotService>(dto.Data);
|
||||
|
||||
@@ -346,7 +346,7 @@
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\BTree.ContentNodeKitSerializer.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\BTree.DictionaryOfCultureVariationSerializer.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\BTree.DictionaryOfPropertyDataSerializer.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\ContentSerializedData.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\ContentNestedData.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\CultureVariation.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\PropertyData.cs" />
|
||||
<Compile Include="PublishedCache\NuCache\DataSource\SerializerBase.cs" />
|
||||
|
||||
Reference in New Issue
Block a user