public Task Insert(FactContext <T> context) { return(context.WorkingMemory.Access(this, x => { x.Add(context.Fact); return _sinks.All(sink => sink.Insert(context)); })); }
Task IFactSink.Insert <T>(FactContext <T> context) { if (!_typeNodes.ContainsKey(typeof(T))) { GetTypeNode <T>(); } return(Task.WhenAll(_typeNodes.Values.Select(x => x.FactSink.Insert(context)))); }
protected Task Matching(FactContext <TRight> context, Func <TupleContext <TLeft>, Task> callback) { return(_leftSource.All(context, async tupleContext => { var match = await Evaluate(context, tupleContext.Tuple, context.Fact).ConfigureAwait(false); if (match) { await callback(new SessionTupleContext <TLeft>(context, tupleContext.Tuple)).ConfigureAwait(false); } })); }
public virtual Task Insert(FactContext <TRight> context) { return(_leftSource.All(context, async tupleContext => { var match = await Evaluate(context, tupleContext.Tuple, context.Fact).ConfigureAwait(false); if (match) { await MemoryNode.Insert(context, tupleContext.Tuple, context.Fact).ConfigureAwait(false); } })); }
public virtual async Task Insert(FactContext <TFact> context) { using (_log.BeginTypeScope(GetType())) { if (Evaluate(context)) { await _childNodes.All(node => node.Insert(context)).ConfigureAwait(false); await _memoryNode.Value.Insert(context).ConfigureAwait(false); } } }
async Task IFactSink.Insert <T>(FactContext <T> factContext) { var typeContext = factContext as FactContext <TFact>; if (typeContext == null) { return; } try { await _observers.PreInsert(typeContext).ConfigureAwait(false); await Insert(typeContext).ConfigureAwait(false); await _observers.PostInsert(typeContext).ConfigureAwait(false); } catch (Exception exception) { await _observers.InsertFault(typeContext, exception).ConfigureAwait(false); throw; } }
public bool Evaluate(FactContext <T> context) { return(_condition(context.Fact)); }
public Task InsertFault <T>(FactContext <T> fact, Exception exception) where T : class { return(Console.Out.WriteLineAsync($"InsertFault:{typeof(T).Name}:{exception}")); }
public Task PostInsert <T>(FactContext <T> fact) where T : class { return(Console.Out.WriteLineAsync($"PostInsert:{typeof(T).Name}")); }
public Task InsertFault(FactContext <TFact> context, Exception exception) { return(_observer.InsertFault(context, exception)); }
public Task PostInsert(FactContext <TFact> context) { return(_observer.PostInsert(context)); }
protected override bool Evaluate(FactContext <T> context) { return(_condition.Evaluate(context)); }
protected virtual bool Evaluate(FactContext <TFact> context) { return(true); }
public Task InsertFault <T>(FactContext <T> fact, Exception exception) where T : class { return(ForEachAsync(x => x.InsertFault(fact, exception))); }
public Task PostInsert <T>(FactContext <T> fact) where T : class { return(ForEachAsync(x => x.PostInsert(fact))); }
protected override bool Evaluate(FactContext <T> context) { return(_matches(context.Fact)); }