Table of Contents

Class RailwayTrackAttribute

Namespace
FunctionalDdd
Assembly
FunctionalDdd.RailwayOrientedProgramming.dll

Indicates which railway track an operation executes on. This metadata can be used by IDE extensions, analyzers, and documentation generators.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class RailwayTrackAttribute : Attribute
Inheritance
RailwayTrackAttribute
Inherited Members
Extension Methods

Examples

[RailwayTrack(TrackBehavior.Success)]
public static Result<TOut> Bind<T, TOut>(this Result<T> result, Func<T, Result<TOut>> func)

[RailwayTrack(TrackBehavior.Failure)]
public static Result<T> TapOnFailure<T>(this Result<T> result, Action<Error> action)

Remarks

Railway-Oriented Programming uses a railway track metaphor where operations flow along either a success track or a failure track. This attribute makes the track behavior explicit and machine-readable.

Track Behaviors:

  • Success - Only executes when Result is successful
  • Failure - Only executes when Result has failed
  • Both - Executes on both success and failure tracks
  • Terminal - Handles both tracks and exits the railway

Constructors

RailwayTrackAttribute(TrackBehavior)

Initializes a new instance of the RailwayTrackAttribute class.

public RailwayTrackAttribute(TrackBehavior track)

Parameters

track TrackBehavior

The track behavior of the operation.

Properties

Track

Gets the track behavior of the annotated operation.

public TrackBehavior Track { get; }

Property Value

TrackBehavior