mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* Renaming Microsoft.Agent.Workflows to Microsoft.Agents.AI.Workflows * Removing local settings. * Removing remining old files from merge.
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Text.Json.Serialization;
|
|
using Microsoft.Agents.AI.Workflows.Execution;
|
|
using Microsoft.Shared.Diagnostics;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Checkpointing;
|
|
|
|
/// <summary>
|
|
/// Base class representing information about an edge in a workflow.
|
|
/// </summary>
|
|
[JsonPolymorphic(UnknownDerivedTypeHandling = JsonUnknownDerivedTypeHandling.FailSerialization)]
|
|
[JsonDerivedType(typeof(DirectEdgeInfo), (int)EdgeKind.Direct)]
|
|
[JsonDerivedType(typeof(FanOutEdgeInfo), (int)EdgeKind.FanOut)]
|
|
[JsonDerivedType(typeof(FanInEdgeInfo), (int)EdgeKind.FanIn)]
|
|
public class EdgeInfo
|
|
{
|
|
/// <summary>
|
|
/// The kind of edge.
|
|
/// </summary>
|
|
public EdgeKind Kind { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the connection information associated with the edge.
|
|
/// </summary>
|
|
public EdgeConnection Connection { get; }
|
|
|
|
[JsonConstructor]
|
|
internal EdgeInfo(EdgeKind kind, EdgeConnection connection)
|
|
{
|
|
this.Kind = kind;
|
|
this.Connection = Throw.IfNull(connection);
|
|
}
|
|
|
|
internal bool IsMatch(Edge edge)
|
|
{
|
|
return this.Kind == edge.Kind
|
|
&& this.Connection.Equals(edge.Data.Connection)
|
|
&& this.IsMatchInternal(edge.Data);
|
|
}
|
|
|
|
internal virtual bool IsMatchInternal(EdgeData edgeData) => true;
|
|
}
|