| | | 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 GraphEdgeEntry : IEquatable<GraphEdgeEntry> |
| | | 9 | | { |
| | | 10 | | public GraphEdgeEntry( |
| | | 11 | | string sourceAgentTypeName, |
| | | 12 | | string sourceAgentClassName, |
| | | 13 | | string graphName, |
| | | 14 | | string targetAgentTypeName, |
| | | 15 | | string? condition, |
| | | 16 | | bool isRequired, |
| | | 17 | | int? nodeRoutingMode) |
| | | 18 | | { |
| | 34 | 19 | | SourceAgentTypeName = sourceAgentTypeName; |
| | 34 | 20 | | SourceAgentClassName = sourceAgentClassName; |
| | 34 | 21 | | GraphName = graphName; |
| | 34 | 22 | | TargetAgentTypeName = targetAgentTypeName; |
| | 34 | 23 | | Condition = condition; |
| | 34 | 24 | | IsRequired = isRequired; |
| | 34 | 25 | | NodeRoutingMode = nodeRoutingMode; |
| | 34 | 26 | | } |
| | | 27 | | |
| | 68 | 28 | | public string SourceAgentTypeName { get; } |
| | 29 | 29 | | public string SourceAgentClassName { get; } |
| | 70 | 30 | | public string GraphName { get; } |
| | 75 | 31 | | public string TargetAgentTypeName { get; } |
| | 89 | 32 | | public string? Condition { get; } |
| | 46 | 33 | | public bool IsRequired { get; } |
| | 38 | 34 | | public int? NodeRoutingMode { get; } |
| | | 35 | | |
| | | 36 | | public bool Equals(GraphEdgeEntry other) => |
| | 9 | 37 | | string.Equals(SourceAgentTypeName, other.SourceAgentTypeName, StringComparison.Ordinal) && |
| | 9 | 38 | | string.Equals(SourceAgentClassName, other.SourceAgentClassName, StringComparison.Ordinal) && |
| | 9 | 39 | | string.Equals(GraphName, other.GraphName, StringComparison.Ordinal) && |
| | 9 | 40 | | string.Equals(TargetAgentTypeName, other.TargetAgentTypeName, StringComparison.Ordinal) && |
| | 9 | 41 | | string.Equals(Condition, other.Condition, StringComparison.Ordinal) && |
| | 9 | 42 | | IsRequired == other.IsRequired && |
| | 9 | 43 | | NodeRoutingMode == other.NodeRoutingMode; |
| | | 44 | | |
| | | 45 | | public override bool Equals(object? obj) => |
| | 2 | 46 | | obj is GraphEdgeEntry other && Equals(other); |
| | | 47 | | |
| | | 48 | | public override int GetHashCode() |
| | | 49 | | { |
| | | 50 | | unchecked |
| | | 51 | | { |
| | 4 | 52 | | var hash = 17; |
| | 4 | 53 | | hash = hash * 31 + (SourceAgentTypeName?.GetHashCode() ?? 0); |
| | 4 | 54 | | hash = hash * 31 + (SourceAgentClassName?.GetHashCode() ?? 0); |
| | 4 | 55 | | hash = hash * 31 + (GraphName?.GetHashCode() ?? 0); |
| | 4 | 56 | | hash = hash * 31 + (TargetAgentTypeName?.GetHashCode() ?? 0); |
| | 4 | 57 | | hash = hash * 31 + (Condition?.GetHashCode() ?? 0); |
| | 4 | 58 | | hash = hash * 31 + IsRequired.GetHashCode(); |
| | 4 | 59 | | hash = hash * 31 + NodeRoutingMode.GetHashCode(); |
| | 4 | 60 | | return hash; |
| | | 61 | | } |
| | | 62 | | } |
| | | 63 | | |
| | | 64 | | public static bool operator ==(GraphEdgeEntry left, GraphEdgeEntry right) => |
| | 2 | 65 | | left.Equals(right); |
| | | 66 | | |
| | | 67 | | public static bool operator !=(GraphEdgeEntry left, GraphEdgeEntry right) => |
| | 2 | 68 | | !left.Equals(right); |
| | | 69 | | } |