* Rename Umbraco.Core namespace to Umbraco.Cms.Core * Move extension methods in core project to Umbraco.Extensions * Move extension methods in core project to Umbraco.Extensions * Rename Umbraco.Examine namespace to Umbraco.Cms.Examine * Move examine extensions to Umbraco.Extensions namespace * Reflect changed namespaces in Builder and fix unit tests * Adjust namespace in Umbraco.ModelsBuilder.Embedded * Adjust namespace in Umbraco.Persistence.SqlCe * Adjust namespace in Umbraco.PublishedCache.NuCache * Align namespaces in Umbraco.Web.BackOffice * Align namespaces in Umbraco.Web.Common * Ensure that SqlCeSupport is still enabled after changing the namespace * Align namespaces in Umbraco.Web.Website * Align namespaces in Umbraco.Web.UI.NetCore * Align namespaces in Umbraco.Tests.Common * Align namespaces in Umbraco.Tests.UnitTests * Align namespaces in Umbraco.Tests.Integration * Fix errors caused by changed namespaces * Fix integration tests * Undo the Umbraco.Examine.Lucene namespace change This breaks integration tests on linux, since the namespace wont exists there because it's only used on windows. * Fix merge * Fix Merge
44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using System;
|
|
|
|
namespace Umbraco.Cms.Core.Collections
|
|
{
|
|
/// <summary>
|
|
/// Represents a composite key of (int, string) for fast dictionaries.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>The integer part of the key must be greater than, or equal to, zero.</para>
|
|
/// <para>The string part of the key is case-insensitive.</para>
|
|
/// <para>Null is a valid value for both parts.</para>
|
|
/// </remarks>
|
|
public struct CompositeIntStringKey : IEquatable<CompositeIntStringKey>
|
|
{
|
|
private readonly int _key1;
|
|
private readonly string _key2;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="CompositeIntStringKey"/> struct.
|
|
/// </summary>
|
|
public CompositeIntStringKey(int? key1, string key2)
|
|
{
|
|
if (key1 < 0) throw new ArgumentOutOfRangeException(nameof(key1));
|
|
_key1 = key1 ?? -1;
|
|
_key2 = key2?.ToLowerInvariant() ?? "NULL";
|
|
}
|
|
|
|
public bool Equals(CompositeIntStringKey other)
|
|
=> _key2 == other._key2 && _key1 == other._key1;
|
|
|
|
public override bool Equals(object obj)
|
|
=> obj is CompositeIntStringKey other && _key2 == other._key2 && _key1 == other._key1;
|
|
|
|
public override int GetHashCode()
|
|
=> _key2.GetHashCode() * 31 + _key1;
|
|
|
|
public static bool operator ==(CompositeIntStringKey key1, CompositeIntStringKey key2)
|
|
=> key1._key2 == key2._key2 && key1._key1 == key2._key1;
|
|
|
|
public static bool operator !=(CompositeIntStringKey key1, CompositeIntStringKey key2)
|
|
=> key1._key2 != key2._key2 || key1._key1 != key2._key1;
|
|
}
|
|
}
|