-
-
Save Konard/087927bdb4c823795d56 to your computer and use it in GitHub Desktop.
Структура описывающая уникальную связь.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Links.Core.Structures | |
{ | |
/// <summary> | |
/// Структура описывающая уникальную связь. | |
/// </summary> | |
public struct Link : IEquatable<Link> | |
{ | |
public readonly Unique Id; | |
public readonly Pair Pair; | |
public Link(Unique id, Pair pair) | |
{ | |
Id = id; | |
Pair = pair; | |
} | |
static public Link Create(Unique id, Pair pair) | |
{ | |
return new Link(id, pair); | |
} | |
public override int GetHashCode() | |
{ | |
var hash = 17; | |
hash = hash * 31 + Id.GetHashCode(); | |
hash = hash * 31 + Pair.GetHashCode(); | |
return hash; | |
} | |
public override bool Equals(object other) | |
{ | |
return other is Link && Equals((Link)other); | |
} | |
public bool Equals(Link other) | |
{ | |
return Id.Equals(other.Id) && | |
Pair.Equals(other.Pair); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment