Skip to content

Instantly share code, notes, and snippets.

@Macadoshis
Created November 29, 2018 13:48
Show Gist options
  • Select an option

  • Save Macadoshis/2ab805f14bf9b5ad6413fe597988a8ed to your computer and use it in GitHub Desktop.

Select an option

Save Macadoshis/2ab805f14bf9b5ad6413fe597988a8ed to your computer and use it in GitHub Desktop.
using System;
namespace CMSS.Domain.Base
{
public abstract class PairItemDom<T> : IEquatable<PairItemDom<T>>
{
protected PairItemDom() : this(null, default(T))
{
}
protected PairItemDom(int? refId, T refValue)
{
this.RefId = refId;
this.RefValue = refValue;
}
public int? RefId { get; set; }
public T RefValue { get; set; }
public bool Equals(PairItemDom<T> other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return RefId == other.RefId;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((PairItemDom<T>)obj);
}
public override int GetHashCode()
{
return RefId.GetHashCode();
}
public static bool AreObjectsEqual(PairItemDom<T> o, PairItemDom<T> o2)
{
if (o == null && o2 == null)
{
return true;
}
if (o == null || o2 == null)
{
return false;
}
return o.Equals(o2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment