Merge branch 'temp8-3527-indexes-via-code' into temp8

This commit is contained in:
Stephan
2018-12-07 09:27:38 +01:00
142 changed files with 6734 additions and 5609 deletions

View File

@@ -70,10 +70,7 @@ namespace Umbraco.Core.Collections
/// The number of elements contained in the <see cref="T:System.Collections.ICollection"/>.
/// </returns>
/// <filterpriority>2</filterpriority>
public int Count
{
get { return GetThreadSafeClone().Count; }
}
public int Count => GetThreadSafeClone().Count;
/// <summary>
/// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
@@ -81,10 +78,7 @@ namespace Umbraco.Core.Collections
/// <returns>
/// true if the <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only; otherwise, false.
/// </returns>
public bool IsReadOnly
{
get { return false; }
}
public bool IsReadOnly => false;
/// <summary>
/// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.

View File

@@ -0,0 +1,19 @@
using System;
using System.ComponentModel;
namespace Umbraco.Core
{
public static partial class Constants
{
public static class UmbracoIndexes
{
public const string InternalIndexName = InternalIndexPath + "Index";
public const string ExternalIndexName = ExternalIndexPath + "Index";
public const string MembersIndexName = MembersIndexPath + "Index";
public const string InternalIndexPath = "Internal";
public const string ExternalIndexPath = "External";
public const string MembersIndexPath = "Members";
}
}
}

View File

@@ -1,11 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using Umbraco.Core.Logging;
namespace Umbraco.Core
{
@@ -14,6 +9,18 @@ namespace Umbraco.Core
///</summary>
public static class EnumerableExtensions
{
/// <summary>
/// Wraps this object instance into an IEnumerable{T} consisting of a single item.
/// </summary>
/// <typeparam name="T"> Type of the object. </typeparam>
/// <param name="item"> The instance that will be wrapped. </param>
/// <returns> An IEnumerable{T} consisting of a single item. </returns>
public static IEnumerable<T> Yield<T>(this T item)
{
// see EnumeratorBenchmarks - this is faster, and allocates less, than returning an array
yield return item;
}
public static IEnumerable<IEnumerable<T>> InGroupsOf<T>(this IEnumerable<T> source, int groupSize)
{
if (source == null)

View File

@@ -5,6 +5,8 @@ using Newtonsoft.Json.Linq;
namespace Umbraco.Core.Models
{
//TODO: Make a property value converter for this!
/// <summary>
/// A model representing the value saved for the grid
/// </summary>
@@ -19,7 +21,7 @@ namespace Umbraco.Core.Models
public class GridSection
{
[JsonProperty("grid")]
public string Grid { get; set; }
public string Grid { get; set; } //fixme: what is this?
[JsonProperty("rows")]
public IEnumerable<GridRow> Rows { get; set; }
@@ -46,7 +48,7 @@ namespace Umbraco.Core.Models
public class GridArea
{
[JsonProperty("grid")]
public string Grid { get; set; }
public string Grid { get; set; } //fixme: what is this?
[JsonProperty("controls")]
public IEnumerable<GridControl> Controls { get; set; }

View File

@@ -19,7 +19,7 @@ namespace Umbraco.Core.Models
if (pageSize > 0)
{
TotalPages = (long)Math.Ceiling(totalItems / (Decimal)pageSize);
TotalPages = (long)Math.Ceiling(totalItems / (decimal)pageSize);
}
else
{

View File

@@ -21,6 +21,10 @@ namespace Umbraco.Core.Models
public PublicAccessEntry(IContent protectedNode, IContent loginNode, IContent noAccessNode, IEnumerable<PublicAccessRule> ruleCollection)
{
if (protectedNode == null) throw new ArgumentNullException(nameof(protectedNode));
if (loginNode == null) throw new ArgumentNullException(nameof(loginNode));
if (noAccessNode == null) throw new ArgumentNullException(nameof(noAccessNode));
LoginNodeId = loginNode.Id;
NoAccessNodeId = noAccessNode.Id;
_protectedNodeId = protectedNode.Id;

View File

@@ -724,8 +724,8 @@ namespace Umbraco.Core
{
return typeConverter;
}
TypeConverter converter = TypeDescriptor.GetConverter(target);
var converter = TypeDescriptor.GetConverter(target);
if (converter.CanConvertFrom(source))
{
return DestinationTypeConverterCache[key] = converter;

View File

@@ -153,6 +153,9 @@ namespace Umbraco.Core.PropertyEditors
set => _defaultConfiguration = value;
}
/// <inheritdoc />
public virtual IPropertyIndexValueFactory PropertyIndexValueFactory => new DefaultPropertyIndexValueFactory();
/// <summary>
/// Creates a value editor instance.
/// </summary>

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
using Umbraco.Core.Models;
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// Provides a default implementation for <see ref="IPropertyIndexValueFactory">, returning a single field to index containing the property value.
/// </summary>
public class DefaultPropertyIndexValueFactory : IPropertyIndexValueFactory
{
/// <inheritdoc />
public IEnumerable<KeyValuePair<string, IEnumerable<object>>> GetIndexValues(Property property, string culture, string segment, bool published)
{
yield return new KeyValuePair<string, IEnumerable<object>>(
property.Alias,
property.GetValue(culture, segment, published).Yield());
}
}
}

View File

@@ -65,5 +65,10 @@ namespace Umbraco.Core.PropertyEditors
/// <para>Is expected to throw if the editor does not support being configured, e.g. for most parameter editors.</para>
/// </remarks>
IConfigurationEditor GetConfigurationEditor();
/// <summary>
/// Gets the index value factory for the editor.
/// </summary>
IPropertyIndexValueFactory PropertyIndexValueFactory { get; }
}
}
}

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
using Umbraco.Core.Models;
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// Represents a property index value factory.
/// </summary>
public interface IPropertyIndexValueFactory
{
/// <summary>
/// Gets the index values for a property.
/// </summary>
/// <remarks>
/// <para>Returns key-value pairs, where keys are indexed field names. By default, that would be the property alias,
/// and there would be only one pair, but some implementations (see for instance the grid one) may return more than
/// one pair, with different indexed field names.</para>
/// <para>And then, values are an enumerable of objects, because each indexed field can in turn have multiple
/// values. By default, there would be only one object: the property value. But some implementations may return
/// more than one value for a given field.</para>
/// </remarks>
IEnumerable<KeyValuePair<string, IEnumerable<object>>> GetIndexValues(Property property, string culture, string segment, bool published);
}
}

View File

@@ -176,10 +176,8 @@ namespace Umbraco.Core.Services
/// <param name="pageIndex">The page number.</param>
/// <param name="pageSize">The page size.</param>
/// <param name="totalRecords">Total number of documents.</param>
/// <param name="orderBy">A field to order by.</param>
/// <param name="orderDirection">The ordering direction.</param>
/// <param name="orderBySystemField">A flag indicating whether the ordering field is a system field.</param>
/// <param name="filter">Query filter.</param>
/// <param name="ordering">Ordering infos.</param>
IEnumerable<IContent> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalRecords,
IQuery<IContent> filter = null, Ordering ordering = null);

View File

@@ -540,7 +540,7 @@ namespace Umbraco.Core
public static string StripHtml(this string text)
{
const string pattern = @"<(.|\n)*?>";
return Regex.Replace(text, pattern, string.Empty);
return Regex.Replace(text, pattern, string.Empty, RegexOptions.Compiled);
}
/// <summary>

View File

@@ -313,6 +313,7 @@
<Compile Include="Constants-PropertyTypeGroups.cs" />
<Compile Include="Constants-Security.cs" />
<Compile Include="Constants-System.cs" />
<Compile Include="Constants-Indexes.cs" />
<Compile Include="Constants-Web.cs" />
<Compile Include="Constants.cs" />
<Compile Include="ContentVariationExtensions.cs" />
@@ -441,6 +442,7 @@
<Compile Include="PropertyEditors\ConfigurationEditorOfTConfiguration.cs" />
<Compile Include="PropertyEditors\DataEditorAttribute.cs" />
<Compile Include="PropertyEditors\ConfigurationEditor.cs" />
<Compile Include="PropertyEditors\DefaultPropertyIndexValueFactory.cs" />
<Compile Include="PropertyEditors\DropDownFlexibleConfiguration.cs" />
<Compile Include="PropertyEditors\EditorType.cs" />
<Compile Include="PropertyEditors\IConfigurationEditor.cs" />
@@ -449,6 +451,7 @@
<Compile Include="PropertyEditors\ImageCropperConfiguration.cs" />
<Compile Include="PropertyEditors\IManifestValueValidator.cs" />
<Compile Include="PropertyEditors\IValueFormatValidator.cs" />
<Compile Include="PropertyEditors\IPropertyIndexValueFactory.cs" />
<Compile Include="PropertyEditors\IValueRequiredValidator.cs" />
<Compile Include="PropertyEditors\LabelConfiguration.cs" />
<Compile Include="PropertyEditors\LabelConfigurationEditor.cs" />