|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Domain
{
public class CompositeId
{
public int Id1 { get; internal set; }
public int Id2 { get; internal set; }
public CompositeId(int id1, int id2)
{
Id1 = id1;
Id2 = id2;
}
internal CompositeId(){}
public override bool Equals(object obj)
{
if (obj == null || !(obj is CompositeId))
return false;
CompositeId inObj = obj as CompositeId;
return CompositeId.AreEqual(this, inObj);
}
public override int GetHashCode()
{
int hash = 7;
hash = 3 * hash + Id1;
hash = 3 * hash + Id2;
return hash;
}
public static bool operator ==(CompositeId t1, CompositeId t2)
{
return CompositeId.AreEqual(t1, t2);
}
public static bool operator !=(CompositeId t1, CompositeId t2)
{
return !CompositeId.AreEqual(t1, t2);
}
private static bool AreEqual(CompositeId t1, CompositeId t2)
{
object objt1 = t1;
object objt2 = t2;
return (objt1 == null && objt2 == null) || (objt1 != null && objt2 != null && (t1.Id1 == t2.Id1 && t1.Id2 == t2.Id2));
}
}
public class CompositeEntity
{
public virtual CompositeId Id { get; internal set; }
public virtual string Data { get; set; }
public CompositeEntity(int id1, int id2)
{
Id = new CompositeId(id1, id2);
}
public CompositeEntity(CompositeId id)
{
Id = id;
}
internal CompositeEntity()
{
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.