Merge conflicts resolved
This commit is contained in:
@@ -1,7 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an <see cref="IPublishedElement"/> type.
|
||||
/// </summary>
|
||||
/// <remarks>Instances implementing the <see cref="IPublishedContentType"/> interface should be
|
||||
/// immutable, ie if the content type changes, then a new instance needs to be created.</remarks>
|
||||
public interface IPublishedContentType2 : IPublishedContentType
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique key for the content type.
|
||||
/// </summary>
|
||||
Guid Key { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents an <see cref="IPublishedElement"/> type.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace Umbraco. Core.Models.PublishedContent
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Creates published content types.
|
||||
/// </summary>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Provides the published model creation service.
|
||||
/// </summary>
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// </summary>
|
||||
/// <remarks>Instances of the <see cref="PublishedContentType"/> class are immutable, ie
|
||||
/// if the content type changes, then a new class needs to be created.</remarks>
|
||||
public class PublishedContentType : IPublishedContentType
|
||||
public class PublishedContentType : IPublishedContentType2
|
||||
{
|
||||
private readonly IPublishedPropertyType[] _propertyTypes;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// Initializes a new instance of the <see cref="PublishedContentType"/> class with a content type.
|
||||
/// </summary>
|
||||
public PublishedContentType(IContentTypeComposition contentType, IPublishedContentTypeFactory factory)
|
||||
: this(contentType.Id, contentType.Alias, contentType.GetItemType(), contentType.CompositionAliases(), contentType.Variations, contentType.IsElement)
|
||||
: this(contentType.Key, contentType.Id, contentType.Alias, contentType.GetItemType(), contentType.CompositionAliases(), contentType.Variations, contentType.IsElement)
|
||||
{
|
||||
var propertyTypes = contentType.CompositionPropertyTypes
|
||||
.Select(x => factory.CreatePropertyType(this, x))
|
||||
@@ -40,8 +40,20 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// <remarks>
|
||||
/// <para>Values are assumed to be consistent and are not checked.</para>
|
||||
/// </remarks>
|
||||
public PublishedContentType(Guid key, int id, string alias, PublishedItemType itemType, IEnumerable<string> compositionAliases, IEnumerable<PublishedPropertyType> propertyTypes, ContentVariation variations, bool isElement = false)
|
||||
: this(key, id, alias, itemType, compositionAliases, variations, isElement)
|
||||
{
|
||||
var propertyTypesA = propertyTypes.ToArray();
|
||||
foreach (var propertyType in propertyTypesA)
|
||||
propertyType.ContentType = this;
|
||||
_propertyTypes = propertyTypesA;
|
||||
|
||||
InitializeIndexes();
|
||||
}
|
||||
|
||||
[Obsolete("Use the overload specifying a key instead")]
|
||||
public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable<string> compositionAliases, IEnumerable<PublishedPropertyType> propertyTypes, ContentVariation variations, bool isElement = false)
|
||||
: this (id, alias, itemType, compositionAliases, variations, isElement)
|
||||
: this (Guid.Empty, id, alias, itemType, compositionAliases, variations, isElement)
|
||||
{
|
||||
var propertyTypesA = propertyTypes.ToArray();
|
||||
foreach (var propertyType in propertyTypesA)
|
||||
@@ -57,16 +69,26 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
/// <remarks>
|
||||
/// <para>Values are assumed to be consistent and are not checked.</para>
|
||||
/// </remarks>
|
||||
public PublishedContentType(Guid key, int id, string alias, PublishedItemType itemType, IEnumerable<string> compositionAliases, Func<IPublishedContentType, IEnumerable<IPublishedPropertyType>> propertyTypes, ContentVariation variations, bool isElement = false)
|
||||
: this(key, id, alias, itemType, compositionAliases, variations, isElement)
|
||||
{
|
||||
_propertyTypes = propertyTypes(this).ToArray();
|
||||
|
||||
InitializeIndexes();
|
||||
}
|
||||
|
||||
[Obsolete("Use the overload specifying a key instead")]
|
||||
public PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable<string> compositionAliases, Func<IPublishedContentType, IEnumerable<IPublishedPropertyType>> propertyTypes, ContentVariation variations, bool isElement = false)
|
||||
: this(id, alias, itemType, compositionAliases, variations, isElement)
|
||||
: this(Guid.Empty, id, alias, itemType, compositionAliases, variations, isElement)
|
||||
{
|
||||
_propertyTypes = propertyTypes(this).ToArray();
|
||||
|
||||
InitializeIndexes();
|
||||
}
|
||||
|
||||
private PublishedContentType(int id, string alias, PublishedItemType itemType, IEnumerable<string> compositionAliases, ContentVariation variations, bool isElement)
|
||||
private PublishedContentType(Guid key, int id, string alias, PublishedItemType itemType, IEnumerable<string> compositionAliases, ContentVariation variations, bool isElement)
|
||||
{
|
||||
Key = key;
|
||||
Id = id;
|
||||
Alias = alias;
|
||||
ItemType = itemType;
|
||||
@@ -115,6 +137,9 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
|
||||
#region Content type
|
||||
|
||||
/// <inheritdoc />
|
||||
public Guid Key { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Id { get; }
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
public static class PublishedContentTypeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the GUID key from an <see cref="IPublishedContentType"/>
|
||||
/// </summary>
|
||||
/// <param name="publishedContentType"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetKey(this IPublishedContentType publishedContentType, out Guid key)
|
||||
{
|
||||
if (publishedContentType is IPublishedContentType2 contentTypeWithKey)
|
||||
{
|
||||
key = contentTypeWithKey.Key;
|
||||
return true;
|
||||
}
|
||||
key = Guid.Empty;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user