namespace Elsa.Client.Models { public struct VersionOptions { /// /// Gets the latest version. /// public static readonly VersionOptions Latest = new VersionOptions { IsLatest = true }; /// /// Gets the published version. /// public static readonly VersionOptions Published = new VersionOptions { IsPublished = true }; /// /// Gets the latest or published version. /// public static readonly VersionOptions LatestOrPublished = new VersionOptions { IsLatestOrPublished = true }; /// /// Gets the draft version. /// public static readonly VersionOptions Draft = new VersionOptions { IsDraft = true }; /// /// Gets all versions. /// public static readonly VersionOptions All = new VersionOptions { AllVersions = true }; /// /// Gets a specific version. /// public static VersionOptions SpecificVersion(int version) => new VersionOptions { Version = version }; public bool IsLatest { get; private set; } public bool IsLatestOrPublished { get; private set; } public bool IsPublished { get; private set; } public bool IsDraft { get; private set; } public bool AllVersions { get; private set; } public int Version { get; private set; } /// /// Returns a simple string representation of this . /// public override string ToString() => AllVersions ? "AllVersions" : IsDraft ? "Draft" : IsLatest ? "Latest" : IsPublished ? "Published" : IsLatestOrPublished ? "LatestOrPublished" : Version.ToString(); /// /// Parses a string into a . /// public static VersionOptions FromString(string value) => value switch { "AllVersions" => All, "Draft" => Draft, "Latest" => Latest, "Published" => Published, "LatestOrPublished" => LatestOrPublished, _ => SpecificVersion(int.Parse(value)) }; } }