Files
Umbraco-CMS/umbraco/presentation.ClientDependency/ClientDependencyList.cs
Shandem a0e3589502 DO NOT DOWNLOAD. DOWNLOAD LATEST STABLE FROM RELEASE TAB
ClientDependency fixes and implementation. Tagged some files for removal.

[TFS Changeset #56112]
2009-07-07 14:27:03 +00:00

47 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace umbraco.presentation.ClientDependency
{
/// <summary>
/// Wraps a HashSet object for the client dependency file type and declares a equality operator
/// </summary>
public class ClientDependencyList : HashSet<IClientDependencyFile>
{
public ClientDependencyList() : base(new ClientDependencyComparer()) { }
internal class ClientDependencyComparer : IEqualityComparer<IClientDependencyFile>
{
#region IEqualityComparer<IClientDependencyFile> Members
/// <summary>
/// If the lowercased combination of the file path, dependency type and path name aliases are the same,
/// then they are the same dependency.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool Equals(IClientDependencyFile x, IClientDependencyFile y)
{
return (x.FilePath.ToLower().Trim() + x.DependencyType.ToString().ToLower() + x.PathNameAlias.ToLower().Trim() ==
y.FilePath.ToLower().Trim() + y.DependencyType.ToString().ToLower() + y.PathNameAlias.ToLower().Trim());
}
public int GetHashCode(IClientDependencyFile obj)
{
return (obj.FilePath.ToLower().Trim() + obj.DependencyType.ToString().ToLower() + obj.PathNameAlias.ToLower().Trim())
.GetHashCode();
}
#endregion
}
}
}