Files
Umbraco-CMS/src/Umbraco.Core/Dynamics/Signature.cs
Shannon Deminick 7175860ae0 Added tests for dynamic node to select children based on the child doc type names including pluralized names and added
support for checking with case insensitivity. Example. CurrentPage.NewsItems where NewsItem is a child doc type alias.
Found one reason why the old dynamic node has performance issues and have added a note, just need to do more reseearch to
make sure my findings are correct.
Changed over all of the new DynamicNode classes to be DynamicDocument instead.
2012-08-18 11:03:30 +06:00

43 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
namespace Umbraco.Core.Dynamics
{
internal class Signature : IEquatable<Signature>
{
public DynamicProperty[] Properties { get; set; }
public int HashCode { get; set; }
public Signature(IEnumerable<DynamicProperty> properties)
{
this.Properties = properties.ToArray();
HashCode = 0;
foreach (DynamicProperty p in this.Properties)
{
HashCode ^= p.Name.GetHashCode() ^ p.Type.GetHashCode();
}
}
public override int GetHashCode()
{
return HashCode;
}
public override bool Equals(object obj)
{
return obj is Signature && Equals((Signature)obj);
}
public bool Equals(Signature other)
{
if (Properties.Length != other.Properties.Length) return false;
for (int i = 0; i < Properties.Length; i++)
{
if (Properties[i].Name != other.Properties[i].Name ||
Properties[i].Type != other.Properties[i].Type) return false;
}
return true;
}
}
}