Beispiel #1
0
        public ElseIfNode(DocumentIdNode documentIdNode, IElseIf elseIf)
        {
            Infra.NotNull(elseIf.Condition);

            documentIdNode.SaveToSlot(out _documentIdSlot);
            _elseIf = elseIf;
        }
Beispiel #2
0
        public ParamNode(DocumentIdNode documentIdNode, IParam param)
        {
            Infra.NotNull(param.Name);

            documentIdNode.SaveToSlot(out _documentIdSlot);
            _param = param;
        }
Beispiel #3
0
        public object Evaluate(XPathCompiledExpression compiledExpression)
        {
            Infra.NotNull(ExecutionContext);

            compiledExpression.SetResolver(this);

            return(new DataModelXPathNavigator(ExecutionContext.DataModel).Evaluate(compiledExpression.XPathExpression) !);
        }
Beispiel #4
0
        public InitialNode(DocumentIdNode documentIdNode, IInitial initial) : base(documentIdNode, children: null)
        {
            Infra.NotNull(initial.Transition);

            _initial   = initial;
            Transition = initial.Transition.As <TransitionNode>();

            Transition.SetSource(this);
        }
Beispiel #5
0
        public HistoryNode(DocumentIdNode documentIdNode, IHistory history) : base(documentIdNode, children: null)
        {
            Infra.NotNull(history.Transition);

            _history = history;

            Id         = history.Id ?? new IdentifierNode(Identifier.New());
            Transition = history.Transition.As <TransitionNode>();
            Transition.SetSource(this);
        }
        public DefaultAssignEvaluator(IAssign assign)
        {
            _assign = assign ?? throw new ArgumentNullException(nameof(assign));

            Infra.NotNull(assign.Location);

            LocationEvaluator      = assign.Location.As <ILocationEvaluator>();
            ExpressionEvaluator    = assign.Expression?.As <IObjectEvaluator>();
            InlineContentEvaluator = assign.InlineContent?.As <IObjectEvaluator>();
        }
Beispiel #7
0
        public CustomActionDispatcher(IErrorProcessor?errorProcessor, ICustomAction customAction, IFactoryContext factoryContext)
        {
            _errorProcessor = errorProcessor;
            _customAction   = customAction;
            _factoryContext = factoryContext;

            Infra.NotNull(customAction.XmlNamespace);
            Infra.NotNull(customAction.XmlName);
            Infra.NotNull(customAction.Xml);
        }
Beispiel #8
0
        public StateMachineNode(DocumentIdNode documentIdNode, IStateMachine stateMachine) : base(documentIdNode, GetChildNodes(stateMachine.Initial, stateMachine.States))
        {
            _stateMachine = stateMachine;

            Infra.NotNull(stateMachine.Initial);

            Initial         = stateMachine.Initial.As <InitialNode>();
            ScriptEvaluator = _stateMachine.Script?.As <ScriptNode>();
            DataModel       = _stateMachine.DataModel?.As <DataModelNode>();
        }
        public DefaultInlineContentEvaluator(IInlineContent inlineContent)
        {
            if (inlineContent is null)
            {
                throw new ArgumentNullException(nameof(inlineContent));
            }

            Infra.NotNull(inlineContent.Value);

            _inlineContent = inlineContent;
        }
Beispiel #10
0
        public DefaultContentBodyEvaluator(IContentBody contentBody)
        {
            if (contentBody is null)
            {
                throw new ArgumentNullException(nameof(contentBody));
            }

            Infra.NotNull(contentBody.Value);

            _contentBody = contentBody;
        }
        public DefaultRaiseEvaluator(IRaise raise)
        {
            if (raise is null)
            {
                throw new ArgumentNullException(nameof(raise));
            }

            Infra.NotNull(raise.OutgoingEvent);

            _raise = raise;
        }
Beispiel #12
0
        public DataNode(DocumentIdNode documentIdNode, IData data)
        {
            Infra.NotNull(data.Id);

            documentIdNode.SaveToSlot(out _documentIdSlot);
            _data = data;

            ResourceEvaluator      = data.Source?.As <IResourceEvaluator>();
            ExpressionEvaluator    = data.Expression?.As <IObjectEvaluator>();
            InlineContentEvaluator = data.InlineContent?.As <IObjectEvaluator>();
        }
Beispiel #13
0
        public ValueTask Execute(IExecutionContext executionContext, CancellationToken token)
        {
            if (executionContext is null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            Infra.NotNull(_executor);

            return(_executor.Execute(executionContext, token));
        }
        public DefaultForEachEvaluator(IForEach forEach)
        {
            _forEach = forEach ?? throw new ArgumentNullException(nameof(forEach));

            Infra.NotNull(forEach.Array);
            Infra.NotNull(forEach.Item);

            ArrayEvaluator      = forEach.Array.As <IArrayEvaluator>();
            ItemEvaluator       = forEach.Item.As <ILocationEvaluator>();
            IndexEvaluator      = forEach.Index?.As <ILocationEvaluator>();
            ActionEvaluatorList = forEach.Action.AsArrayOf <IExecutableEntity, IExecEvaluator>();
        }
Beispiel #15
0
        public DefaultParam(IParam param)
        {
            if (param is null)
            {
                throw new ArgumentNullException(nameof(param));
            }

            Infra.NotNull(param.Name);

            _param = param;
            ExpressionEvaluator = param.Expression?.As <IObjectEvaluator>();
            LocationEvaluator   = param.Location?.As <ILocationEvaluator>();
        }
        public DefaultCustomActionEvaluator(ICustomAction customAction)
        {
            _customAction = customAction;

            var customActionDispatcher = customAction.As <ICustomActionDispatcher>();

            Infra.NotNull(customActionDispatcher, Resources.Assertion_CustomActionDoesNotConfigured);

            var locations = customAction.Locations.AsArrayOf <ILocationExpression, ILocationEvaluator>(true);
            var values    = customAction.Values.AsArrayOf <IValueExpression, IValueEvaluator>(true);

            customActionDispatcher.SetEvaluators(locations, values);

            _customActionDispatcher = customActionDispatcher;
        }
Beispiel #17
0
        IExpressionEvaluator ICustomActionContext.RegisterValueExpression(string expression, ExpectedValueType expectedValueType)
        {
            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            Infra.NotNull(_executor, Resources.Exception_RegistrationShouldNoOccurAfterInitialization);

            _values ??= ImmutableArray.CreateBuilder <IValueExpression>();

            var expressionEvaluator = new ExpressionEvaluator(this, _values.Count, expression, expectedValueType);

            _values.Add(expressionEvaluator);

            return(expressionEvaluator);
        }
Beispiel #18
0
        public InvokeNode(DocumentIdNode documentIdNode, IInvoke invoke)
        {
            documentIdNode.SaveToSlot(out _documentIdSlot);
            _invoke = invoke;

            Finalize = invoke.Finalize?.As <FinalizeNode>();

            var startInvokeEvaluator = invoke.As <IStartInvokeEvaluator>();

            Infra.NotNull(startInvokeEvaluator);
            _startInvokeEvaluator = startInvokeEvaluator;

            var cancelInvokeEvaluator = invoke.As <ICancelInvokeEvaluator>();

            Infra.NotNull(cancelInvokeEvaluator);
            _cancelInvokeEvaluator = cancelInvokeEvaluator;
        }
Beispiel #19
0
        ILocationAssigner ICustomActionContext.RegisterLocationExpression(string expression)
        {
            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            Infra.NotNull(_executor, Resources.Exception_RegistrationShouldNoOccurAfterInitialization);

            _locations ??= ImmutableArray.CreateBuilder <ILocationExpression>();

            var locationAssigner = new LocationAssigner(this, _locations.Count, expression);

            _locations.Add(locationAssigner);

            return(locationAssigner);
        }
Beispiel #20
0
        public virtual async ValueTask <InvokeId> Start(IIdentifier stateId, IExecutionContext executionContext, CancellationToken token)
        {
            if (stateId is null)
            {
                throw new ArgumentNullException(nameof(stateId));
            }
            if (executionContext is null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            var invokeId = InvokeId.New(stateId, _invoke.Id);

            if (IdLocationEvaluator is not null)
            {
                await IdLocationEvaluator.SetValue(invokeId, executionContext, token).ConfigureAwait(false);
            }

            var type = TypeExpressionEvaluator is not null?ToUri(await TypeExpressionEvaluator.EvaluateString(executionContext, token).ConfigureAwait(false)) : _invoke.Type;

            var source = SourceExpressionEvaluator is not null?ToUri(await SourceExpressionEvaluator.EvaluateString(executionContext, token).ConfigureAwait(false)) : _invoke.Source;

            var rawContent = ContentBodyEvaluator is IStringEvaluator rawContentEvaluator ? await rawContentEvaluator.EvaluateString(executionContext, token).ConfigureAwait(false) : null;

            var content = await DataConverter.GetContent(ContentBodyEvaluator, ContentExpressionEvaluator, executionContext, token).ConfigureAwait(false);

            var parameters = await DataConverter.GetParameters(NameEvaluatorList, ParameterList, executionContext, token).ConfigureAwait(false);

            Infra.NotNull(type);

            var invokeData = new InvokeData(invokeId, type)
            {
                Source     = source,
                RawContent = rawContent,
                Content    = content,
                Parameters = parameters
            };

            await executionContext.StartInvoke(invokeData, token).ConfigureAwait(false);

            return(invokeId);
        }
Beispiel #21
0
        public async ValueTask CheckPoint(int level, CancellationToken token)
        {
            if (level < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(level));
            }

            Infra.NotNull(_inMemoryStorage);

            var transactionLogSize = _inMemoryStorage.GetTransactionLogSize();

            if (transactionLogSize == 0)
            {
                return;
            }

            if (level == 0)
            {
                _canShrink = true;
            }

            var buf = ArrayPool <byte> .Shared.Rent(transactionLogSize + 2 *MaxInt32Length);

            try
            {
                var mark           = (level << 1) + 1;
                var markSizeLength = GetMarkSizeLength(mark, transactionLogSize);
                WriteMarkSize(buf.AsSpan(start: 0, markSizeLength), mark, transactionLogSize);

                _inMemoryStorage.WriteTransactionLogToSpan(buf.AsSpan(markSizeLength));

                await _stream.WriteAsync(buf, offset : 0, markSizeLength + transactionLogSize, token).ConfigureAwait(false);

                await _stream.FlushAsync(token).ConfigureAwait(false);
            }
            finally
            {
                ArrayPool <byte> .Shared.Return(buf);
            }
        }
Beispiel #22
0
        public DefaultIfEvaluator(IIf @if)
        {
            _if = @if ?? throw new ArgumentNullException(nameof(@if));

            Infra.NotNull(@if.Condition);

            var currentCondition = @if.Condition.As <IBooleanEvaluator>();
            var currentActions   = ImmutableArray.CreateBuilder <IExecEvaluator>();
            var branchesBuilder  = ImmutableArray.CreateBuilder <(IBooleanEvaluator?Condition, ImmutableArray <IExecEvaluator> Actions)>();

            foreach (var op in @if.Action)
            {
                switch (op)
                {
                case IElseIf elseIf:
                    branchesBuilder.Add((currentCondition, currentActions.ToImmutable()));
                    Infra.NotNull(elseIf.Condition);
                    currentCondition = elseIf.Condition.As <IBooleanEvaluator>();
                    currentActions.Clear();
                    break;

                case IElse:
                    branchesBuilder.Add((currentCondition, currentActions.ToImmutable()));
                    currentCondition = default !;
                    currentActions.Clear();
                    break;

                default:
                    currentActions.Add(op.As <IExecEvaluator>());
                    break;
                }
            }

            branchesBuilder.Add((currentCondition, currentActions.ToImmutable()));

            Branches = branchesBuilder.ToImmutable();
        }
Beispiel #23
0
        public XIncludeReader(XmlReader innerReader,
                              XmlReaderSettings xmlReaderSettings,
                              XmlResolver xmlResolver,
                              int maxNestingLevel)
            : base(new XmlBaseReader(innerReader, xmlResolver))
        {
            if (innerReader is null)
            {
                throw new ArgumentNullException(nameof(innerReader));
            }
            if (maxNestingLevel < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxNestingLevel));
            }

            _xmlReaderSettings = xmlReaderSettings ?? throw new ArgumentNullException(nameof(xmlReaderSettings));
            _xmlResolver       = xmlResolver ?? throw new ArgumentNullException(nameof(xmlResolver));
            _maxNestingLevel   = maxNestingLevel;

            var nameTable = innerReader.NameTable;

            Infra.NotNull(nameTable);
            _strings = new Strings(nameTable);
        }
Beispiel #24
0
        public PersistedEventSchedulerFactory(StateMachineHostOptions options)
        {
            Infra.NotNull(options.StorageProvider);

            _storageProvider = options.StorageProvider;
        }
        public ScriptExpressionNode(IScriptExpression scriptExpression)
        {
            Infra.NotNull(scriptExpression.Expression);

            _scriptExpression = scriptExpression;
        }
Beispiel #26
0
 public CompoundNode(DocumentIdNode documentIdNode, IState state) : base(documentIdNode, state)
 {
     Infra.NotNull(base.Initial);
 }
Beispiel #27
0
        public async ValueTask Start(IExecutionContext executionContext, CancellationToken token)
        {
            Infra.NotNull(_stateId, Resources.Exception_StateIdNotInitialized);

            InvokeId = await _startInvokeEvaluator.Start(_stateId, executionContext, token).ConfigureAwait(false);
        }
Beispiel #28
0
        public void LeaveScope()
        {
            Infra.NotNull(_scopeStack);

            _scopeStack.Pop();
        }
Beispiel #29
0
        public ExternalDataExpressionNode(IExternalDataExpression externalDataExpression)
        {
            Infra.NotNull(externalDataExpression.Uri);

            _externalDataExpression = externalDataExpression;
        }
Beispiel #30
0
        public CustomActionNode(DocumentIdNode documentIdNode, ICustomAction customAction) : base(documentIdNode, customAction)
        {
            Infra.NotNull(customAction.Xml);

            _customAction = customAction;
        }