Skip to content

Instantly share code, notes, and snippets.

@emiaj
Created October 28, 2011 23:57
Show Gist options
  • Select an option

  • Save emiaj/1323872 to your computer and use it in GitHub Desktop.

Select an option

Save emiaj/1323872 to your computer and use it in GitHub Desktop.
public class AssetFilesKey
{
private readonly List<string> _names;
private readonly List<string> _sortedNames;
public AssetFilesKey(IEnumerable<string> names)
{
_names = names.ToList();
_sortedNames = _names.OrderBy(x => x).ToList();
//_names.Sort();
}
public List<string> Names
{
get { return _names; }
}
public bool Equals(AssetFilesKey other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
if (other._names.Count != _names.Count) return false;
return !other._sortedNames.Where((t, i) => t != _sortedNames[i]).Any();
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof (AssetFilesKey)) return false;
return Equals((AssetFilesKey) obj);
}
public override int GetHashCode()
{
return (_names != null ? _names.Join("-").GetHashCode() : 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment