Beispiel #1
0
 /// <inheritdoc />
 public async ValueTask DisposeAsync()
 {
     foreach (var value in _scopedStateDictionary.Values)
     {
         await StateMonad.DisposeVariableAsync(value, this);
     }
 }
Beispiel #2
0
        /// <inheritdoc />
        public async Task RemoveVariableAsync(VariableName key, bool dispose, IStep?callingStep)
        {
            if (_scopedStateDictionary.Remove(key, out var v) && dispose)
            {
                await StateMonad.DisposeVariableAsync(v, this);
            }

            if (_fixedState.ContainsKey(key))
            {
                Logger.LogSituation(
                    LogSituation.RemoveVariableOutOfScope,
                    callingStep,
                    this,
                    new[] { key }
                    );
            }
        }
Beispiel #3
0
        /// <inheritdoc />
        public Result <T, IErrorBuilder> GetVariable <T>(VariableName key)
        {
            var r1 = StateMonad.TryGetVariableFromDictionary <T>(key, _scopedStateDictionary);

            if (r1.IsFailure)
            {
                return(r1.ConvertFailure <T>());
            }

            if (r1.Value.HasValue)
            {
                return(r1.Value.Value);
            }

            var r2 = StateMonad
                     .TryGetVariableFromDictionary <T>(key, _fixedState)
                     .Bind(
                x => x.ToResult <T, IErrorBuilder>(new ErrorBuilder(ErrorCode.MissingVariable, key))
                );

            return(r2);
        }