M Core/NosSmooth.Core/Contracts/ContractBuilder.cs => Core/NosSmooth.Core/Contracts/ContractBuilder.cs +4 -3
@@ 7,6 7,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Threading;
using System.Threading.Tasks;
using Remora.Results;
@@ 190,11 191,11 @@ public class ContractBuilder<TData, TState, TError>
/// <param name="nextState">The state to move to.</param>
/// <returns>The updated builder.</returns>
public ContractBuilder<TData, TState, TError> SetMoveAction
- (TState state, Func<object?, Task<Result<bool>>> actionFilter, TState nextState)
+ (TState state, Func<object?, CancellationToken, Task<Result<bool>>> actionFilter, TState nextState)
{
_actions[state] = async (data, ct) =>
{
- var filterResult = await actionFilter(data);
+ var filterResult = await actionFilter(data, ct);
if (!filterResult.IsDefined(out var filter))
{
return Result<(TError?, TState?)>.FromError(filterResult);
@@ 215,7 216,7 @@ public class ContractBuilder<TData, TState, TError>
/// </summary>
/// <returns>The contract.</returns>
/// <exception cref="InvalidOperationException">Thrown in case FillAtState or FillData is null.</exception>
- public IContract Build()
+ public IContract<TData, TState> Build()
{
if (_fillAtState is null)
{
A Core/NosSmooth.Core/Contracts/DefaultStates.cs => Core/NosSmooth.Core/Contracts/DefaultStates.cs +28 -0
@@ 0,0 1,28 @@
+//
+// DefaultStates.cs
+//
+// Copyright (c) František Boháček. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace NosSmooth.Core.Contracts;
+
+/// <summary>
+/// Default states used for contracts.
+/// </summary>
+public enum DefaultStates
+{
+ /// <summary>
+ /// Contract has not been executed yet.
+ /// </summary>
+ None,
+
+ /// <summary>
+ /// The contract has requested a response, waiting for it.
+ /// </summary>
+ Requested,
+
+ /// <summary>
+ /// The response was obtained.
+ /// </summary>
+ ResponseObtained
+}<
\ No newline at end of file
A Core/NosSmooth.Core/Contracts/NoErrors.cs => Core/NosSmooth.Core/Contracts/NoErrors.cs +14 -0
@@ 0,0 1,14 @@
+//
+// NoErrors.cs
+//
+// Copyright (c) František Boháček. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+namespace NosSmooth.Core.Contracts;
+
+/// <summary>
+/// Empty enum for contracts without errors.
+/// </summary>
+public enum NoErrors
+{
+}<
\ No newline at end of file