public IEnumerable <Rule <TTarget, TComparison> > GetRules <TTarget, TComparison>() { var ruleDtos = _ruleStore.GetRules <TTarget, TComparison>(); var targetTypeName = typeof(TTarget).Name; var matchingRecords = ruleDtos .Where(r => string.Equals(r.TargetTypeName, targetTypeName, StringComparison.CurrentCultureIgnoreCase)); var targetRuleDefinitions = matchingRecords.Select(GetRuleDefinition); var applicableRulesDefinitions = targetRuleDefinitions.Where( r => r.RuleConditions.All( rc => string.Equals(typeof(TComparison).Name, rc.ComparisonTypeName, StringComparison.CurrentCultureIgnoreCase) || rc.ComparisonType == RuleObject.Constant)); return(applicableRulesDefinitions.Join(matchingRecords, def => def.Id, dto => dto.Id, (def, dto) => new { RuleDefinition = def, RuleDto = dto }) .Select(rule => new Rule <TTarget, TComparison> { Id = rule.RuleDto.Id, Name = rule.RuleDto.Name, Expression = rule.RuleDto.RuleExpression, Validate = _interpreter.Interpret <TTarget, TComparison>(rule.RuleDefinition) }) .ToList()); }
public async Task <IEnumerable <T> > Handle(SideEffect <T> sideEffect, CancellationToken cancellationToken = default) { var tasks = sideEffect.EffectList.Select(effect => _interpreter.Interpret(effect, cancellationToken)).ToList(); await Task.WhenAll(tasks); return(tasks.Select(t => t.Result)); }
private async Task <bool> CheckStepCondition(BehaviorContext context, BehaviorStep step) { if (!string.IsNullOrEmpty(step.Condition?.Instruction)) { if (step.Condition.Instruction.Equals(DefaultBehaviorInstructionNone)) { return(true); } if (step.Condition.Instruction.Equals(DefaultBehaviorInstructionNext)) { return(false); } return((await _interpreter.Interpret(step.Condition, context.Dialog, context.Database, context.ServiceContext.TransportName)).GetTypedResult <bool>()); } return(false); }
private void Run(params string[] sourceCode) { var scanner = new EnkelLexer(sourceCode); var tokens = scanner.Tokens(); var parser = new EnkelParser(tokens); var statements = parser.Parse().ToList(); var resolver = new Resolver(_interpreter); resolver.Resolve(statements); _interpreter.Interpret(statements); }
public object Interpret(BaseSchema schema, object value, IProcessContext context, string path) { if (value == null || !CanInterpret(schema)) { return(value); } if (value is MarkdownDocument val) { return(MarkupCore(val, context, path)); } return(_inner.Interpret(schema, value, context, path)); }
public object Interpret(BaseSchema schema, object value, IProcessContext context, string path) { if (value == null || !CanInterpret(schema) || !(value is string val)) { return(value); } // If *content is from an included file, it should be marked instead of consider it as a placeholder if ((schema == null || schema.Reference == ReferenceType.None) && context.ContentAnchorParser != null) { return(context.ContentAnchorParser.Parse(val)); } return(_inner.Interpret(schema, value, context, path)); }
public bool ProcessCommand(string command, Entity entity) { var userId = entity.GetComponent <PlayerInputComponent>().userId; var commandFound = false; var cleanCommand = command.Trim().ToLower(); var interpretedCommand = _interpreter.Interpret(cleanCommand); foreach (KeyValuePair <string, Action <Entity, String> > cmd in CommandList) { if (cmd.Key.StartsWith(command)) { cmd.Value(entity, interpretedCommand.argument); commandFound = true; } } return(commandFound); }
public async Task Save <TData>(Instance <TData> instance, CancellationToken cancellationToken = default) where TData : new() { var events = instance.GetUncommittedChanges().ToList(); var effects = instance.GetUncommittedEffects().ToList(); var streamId = instance.GetStream(); var aggregateLoadedAtVersion = instance.Version; instance.MarkChangesAsCommitted(); await _eventStore.AppendEventsToStreamAsync(streamId, events, aggregateLoadedAtVersion, cancellationToken); foreach (var effect in effects) { await _interpreter.Interpret(effect, cancellationToken); } }
public void Run() { if (_fileNames.Count == 0) { Console.WriteLine("No input files have been given!"); } else { string input = GetInput(); AST ast = _lexParse.Run(input, _printParseTree); _referenceHandler.InsertReferences(ast); _typeChecker.CheckTypes(ast); List <LabelGraph> output = _interpreter.Interpret(ast); List <ExtensionalGraph> gmlGraphs = _outputGenerator.Generate(output); _fileGenerator.Export(gmlGraphs, _output, _printOutput, _saveOutput, _projectFolder); } }
public Task <T> Interpret <T>(Effect <T> effect, CancellationToken cancellationToken = default) => _interpreter.Interpret(effect, cancellationToken);
public static async Task Interpret(this IInterpreter interpreter, IEffect effect, CancellationToken cancellationToken = default) { var _ = await interpreter.Interpret(effect, cancellationToken); }
public void Interpret() { interpreter.Interpret(); }
public void Interpret_With_No_Arguments_IsSuccessful() { var output = interpreter.Interpret("look"); Assert.Equal("look", output.commandName); }