Revert files that shouldn't change back in v11
This commit is contained in:
@@ -1,42 +1,31 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
namespace Umbraco.Extensions;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods to <see cref="Enum" />.
|
||||
/// </summary>
|
||||
public static class EnumExtensions
|
||||
namespace Umbraco.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether all the flags/bits are set within the enum value.
|
||||
/// Provides extension methods to <see cref="Enum"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The enum type.</typeparam>
|
||||
/// <param name="value">The enum value.</param>
|
||||
/// <param name="flags">The flags.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if all the flags/bits are set within the enum value; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
[Obsolete("Use Enum.HasFlag() or bitwise operations (if performance is important) instead.")]
|
||||
public static bool HasFlagAll<T>(this T value, T flags)
|
||||
where T : Enum =>
|
||||
value.HasFlag(flags);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether any of the flags/bits are set within the enum value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The enum type.</typeparam>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="flags">The flags.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if any of the flags/bits are set within the enum value; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public static bool HasFlagAny<T>(this T value, T flags)
|
||||
where T : Enum
|
||||
public static class EnumExtensions
|
||||
{
|
||||
var v = Convert.ToUInt64(value);
|
||||
var f = Convert.ToUInt64(flags);
|
||||
/// <summary>
|
||||
/// Determines whether any of the flags/bits are set within the enum value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The enum type.</typeparam>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <param name="flags">The flags.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if any of the flags/bits are set within the enum value; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public static bool HasFlagAny<T>(this T value, T flags)
|
||||
where T : Enum
|
||||
{
|
||||
var v = Convert.ToUInt64(value);
|
||||
var f = Convert.ToUInt64(flags);
|
||||
|
||||
return (v & f) > 0;
|
||||
return (v & f) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ namespace Umbraco.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Get concatenated user and default character replacements
|
||||
/// taking into account <see cref="RequestHandlerSettings.EnableDefaultCharReplacements" />
|
||||
/// taking into account <see cref="RequestHandlerSettings.EnableDefaultCharReplacements" />.
|
||||
/// </summary>
|
||||
public static class RequestHandlerSettingsExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Get concatenated user and default character replacements
|
||||
/// taking into account <see cref="RequestHandlerSettings.EnableDefaultCharReplacements" />
|
||||
/// taking into account <see cref="RequestHandlerSettings.EnableDefaultCharReplacements" />.
|
||||
/// </summary>
|
||||
public static IEnumerable<CharItem> GetCharReplacements(this RequestHandlerSettings requestHandlerSettings)
|
||||
{
|
||||
@@ -28,31 +28,8 @@ public static class RequestHandlerSettingsExtension
|
||||
return RequestHandlerSettings.DefaultCharCollection;
|
||||
}
|
||||
|
||||
return MergeUnique(
|
||||
requestHandlerSettings.UserDefinedCharCollection,
|
||||
RequestHandlerSettings.DefaultCharCollection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges CharCollection and UserDefinedCharCollection, prioritizing UserDefinedCharCollection
|
||||
/// </summary>
|
||||
internal static void MergeReplacements(
|
||||
this RequestHandlerSettings requestHandlerSettings,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
var sectionKey = $"{Constants.Configuration.ConfigRequestHandler}:";
|
||||
|
||||
IEnumerable<CharItem> charCollection = GetReplacements(
|
||||
configuration,
|
||||
$"{sectionKey}{nameof(RequestHandlerSettings.CharCollection)}");
|
||||
|
||||
IEnumerable<CharItem> userDefinedCharCollection = GetReplacements(
|
||||
configuration,
|
||||
$"{sectionKey}{nameof(requestHandlerSettings.UserDefinedCharCollection)}");
|
||||
|
||||
IEnumerable<CharItem> mergedCollection = MergeUnique(userDefinedCharCollection, charCollection);
|
||||
|
||||
requestHandlerSettings.UserDefinedCharCollection = mergedCollection;
|
||||
/// Merges CharCollection and UserDefinedCharCollection, prioritizing UserDefinedCharCollection.
|
||||
return MergeUnique(requestHandlerSettings.UserDefinedCharCollection, RequestHandlerSettings.DefaultCharCollection);
|
||||
}
|
||||
|
||||
private static IEnumerable<CharItem> GetReplacements(IConfiguration configuration, string key)
|
||||
@@ -64,6 +41,12 @@ public static class RequestHandlerSettingsExtension
|
||||
{
|
||||
var @char = section.GetValue<string>(nameof(CharItem.Char));
|
||||
var replacement = section.GetValue<string>(nameof(CharItem.Replacement));
|
||||
|
||||
if (@char is null || replacement is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
replacements.Add(new CharItem { Char = @char, Replacement = replacement });
|
||||
}
|
||||
|
||||
@@ -71,8 +54,7 @@ public static class RequestHandlerSettingsExtension
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges two IEnumerable of CharItem without any duplicates, items in priorityReplacements will override those in
|
||||
/// alternativeReplacements
|
||||
/// Merges two IEnumerable of CharItem without any duplicates, items in priorityReplacements will override those in alternativeReplacements.
|
||||
/// </summary>
|
||||
private static IEnumerable<CharItem> MergeUnique(
|
||||
IEnumerable<CharItem> priorityReplacements,
|
||||
|
||||
Reference in New Issue
Block a user