private static T Deserialize <T>(FactGraph graph, FactReference reference) { var emitter = new Emitter(graph, DeserializerCache.Empty); var runtimeFact = emitter.Deserialize <T>(reference); return(runtimeFact); }
public TFact Deserialize <TFact>(FactReference reference) { Type type = typeof(TFact); object runtimeFact = DeserializeToType(reference, type); return((TFact)runtimeFact); }
public TFact Deserialize <TFact>(FactGraph graph, FactReference reference) { lock (this) { var emitter = new Emitter(graph, deserializerCache); var fact = emitter.Deserialize <TFact>(reference); deserializerCache = emitter.DeserializerCache; return(fact); } }
private ImmutableList <Product> ExecutePipeline(FactReference startReference, Pipeline pipeline) { var initialTag = pipeline.Starts.Single().Name; var startingProducts = new Product[] { Product.Empty.With(initialTag, new SimpleElement(startReference)) }.ToImmutableList(); return(pipeline.Paths.Aggregate( startingProducts, (products, path) => ExecutePath(products, path, pipeline) )); }
private ImmutableList <FactReference> ExecuteSteps(FactReference startingFactReference, Path path) { var startingSet = new FactReference[] { startingFactReference }.ToImmutableList(); var afterPredecessors = path.PredecessorSteps .Aggregate(startingSet, (set, predecessorStep) => ExecutePredecessorStep( set, predecessorStep.Role, predecessorStep.TargetType )); var afterSuccessors = path.SuccessorSteps .Aggregate(afterPredecessors, (set, successorStep) => ExecuteSuccessorStep( set, successorStep.Role, successorStep.TargetType )); return(afterSuccessors); }
private ImmutableList <FactReference> ExecuteSteps(Element element, FactGraph graph) { if (element is SimpleElement simple) { var startingFactReference = simple.FactReference; var startingSet = new FactReference[] { startingFactReference }.ToImmutableList(); var afterPredecessors = PredecessorSteps .Aggregate(startingSet, (set, predecessorStep) => ExecutePredecessorStep( set, predecessorStep.Role, predecessorStep.TargetType, graph )); return(afterPredecessors); } else { throw new NotImplementedException(); } }
public object DeserializeToType(FactReference reference, Type type) { if (!objectByReference.TryGetValue(reference, out var runtimeFact)) { var(newCache, deserializer) = DeserializerCache.GetDeserializer(type); DeserializerCache = newCache; try { runtimeFact = deserializer(graph.GetFact(reference), this); objectByReference = objectByReference.Add(reference, runtimeFact); } catch (TargetInvocationException tie) { throw tie.InnerException; } } return(runtimeFact); }
public SimpleElement(FactReference factReference) { FactReference = factReference; }
private bool ConditionIsTrue(FactReference factReference, Pipeline pipeline, bool wantAny) { var hasAny = ExecutePipeline(factReference, pipeline).Any(); return(wantAny && hasAny || !wantAny && !hasAny); }
public Edge(FactReference predecessor, string role, FactReference successor) { Predecessor = predecessor; Role = role; Successor = successor; }
public ImmutableList <Product> Execute(FactReference startReference, FactGraph graph) { return(Execute(ImmutableList <FactReference> .Empty.Add(startReference), graph)); }