From 72b5ea6b07d233eacb75a05344f06b50c3093166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Wed, 11 Jan 2023 22:13:53 +0100 Subject: [PATCH] feat(core): add contract builder outline --- .../Contracts/ContractBuilder.cs | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Core/NosSmooth.Core/Contracts/ContractBuilder.cs diff --git a/Core/NosSmooth.Core/Contracts/ContractBuilder.cs b/Core/NosSmooth.Core/Contracts/ContractBuilder.cs new file mode 100644 index 0000000..f521b9a --- /dev/null +++ b/Core/NosSmooth.Core/Contracts/ContractBuilder.cs @@ -0,0 +1,80 @@ +// +// ContractBuilder.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. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Remora.Results; + +namespace NosSmooth.Core.Contracts; + +/// +/// Builds with given states +/// and errors. +/// +/// The data type. +/// The states. +/// The errors that may be returned. +public class ContractBuilder + where TState : struct, IComparable + where TError : struct + where TData : notnull +{ + private readonly Contractor _contractor; + private readonly TState _defaultState; + + private TState? _fillAtState; + private DefaultContract.FillDataAsync? _fillData; + private Dictionary.StateActionAsync> _actions; + + /// + /// Initializes a new instance of the class. + /// + /// The contractor. + /// The default state of the contract. + public ContractBuilder(Contractor contractor, TState defaultState) + { + _contractor = contractor; + _defaultState = defaultState; + _actions = new Dictionary.StateActionAsync>(); + } + + public ContractBuilder SetMoveFilter(TState state, Func filter, TState nextState) + { + + } + + public ContractBuilder SetMoveFilter(TState state, TState nextState) + { + + } + + public ContractBuilder SetFillData(TState state, Func> fillData) + { + _fillAtState = state; + _fillData = fillData; + } + + public ContractBuilder SetError(TState state, Func error, TState nextState) + { + + } + + public ContractBuilder SetMoveAction(TState state, Func>> actionFilter, TState nextState) + { + + } + + public ContractBuilder SetPacketError(TState state, Func error, TState nextState) + { + + } + + public IContract Build() + { + new DefaultContract() + } +} \ No newline at end of file -- 2.48.1