| | | 1 | | // Copyright (c) NexusLabs. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | |
| | | 6 | | namespace NexusLabs.Needlr.AgentFramework.Generators; |
| | | 7 | | |
| | | 8 | | internal readonly struct GraphNodeEntry : IEquatable<GraphNodeEntry> |
| | | 9 | | { |
| | | 10 | | public GraphNodeEntry( |
| | | 11 | | string agentTypeName, |
| | | 12 | | string agentClassName, |
| | | 13 | | string graphName, |
| | | 14 | | int joinMode) |
| | | 15 | | { |
| | 9 | 16 | | AgentTypeName = agentTypeName; |
| | 9 | 17 | | AgentClassName = agentClassName; |
| | 9 | 18 | | GraphName = graphName; |
| | 9 | 19 | | JoinMode = joinMode; |
| | 9 | 20 | | } |
| | | 21 | | |
| | 16 | 22 | | public string AgentTypeName { get; } |
| | 15 | 23 | | public string AgentClassName { get; } |
| | 18 | 24 | | public string GraphName { get; } |
| | 18 | 25 | | public int JoinMode { get; } |
| | | 26 | | |
| | | 27 | | public bool Equals(GraphNodeEntry other) => |
| | 6 | 28 | | string.Equals(AgentTypeName, other.AgentTypeName, StringComparison.Ordinal) && |
| | 6 | 29 | | string.Equals(AgentClassName, other.AgentClassName, StringComparison.Ordinal) && |
| | 6 | 30 | | string.Equals(GraphName, other.GraphName, StringComparison.Ordinal) && |
| | 6 | 31 | | JoinMode == other.JoinMode; |
| | | 32 | | |
| | | 33 | | public override bool Equals(object? obj) => |
| | 2 | 34 | | obj is GraphNodeEntry other && Equals(other); |
| | | 35 | | |
| | | 36 | | public override int GetHashCode() |
| | | 37 | | { |
| | | 38 | | unchecked |
| | | 39 | | { |
| | 2 | 40 | | var hash = 17; |
| | 2 | 41 | | hash = hash * 31 + (AgentTypeName?.GetHashCode() ?? 0); |
| | 2 | 42 | | hash = hash * 31 + (AgentClassName?.GetHashCode() ?? 0); |
| | 2 | 43 | | hash = hash * 31 + (GraphName?.GetHashCode() ?? 0); |
| | 2 | 44 | | hash = hash * 31 + JoinMode.GetHashCode(); |
| | 2 | 45 | | return hash; |
| | | 46 | | } |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | public static bool operator ==(GraphNodeEntry left, GraphNodeEntry right) => |
| | 1 | 50 | | left.Equals(right); |
| | | 51 | | |
| | | 52 | | public static bool operator !=(GraphNodeEntry left, GraphNodeEntry right) => |
| | 2 | 53 | | !left.Equals(right); |
| | | 54 | | } |