Esempio n. 1
0
        private static T Deserialize <T>(FactGraph graph, FactReference reference)
        {
            var emitter     = new Emitter(graph, DeserializerCache.Empty);
            var runtimeFact = emitter.Deserialize <T>(reference);

            return(runtimeFact);
        }
Esempio n. 2
0
        public TFact Deserialize <TFact>(FactReference reference)
        {
            Type   type        = typeof(TFact);
            object runtimeFact = DeserializeToType(reference, type);

            return((TFact)runtimeFact);
        }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
        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)
                       ));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 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();
     }
 }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public SimpleElement(FactReference factReference)
 {
     FactReference = factReference;
 }
Esempio n. 9
0
        private bool ConditionIsTrue(FactReference factReference, Pipeline pipeline, bool wantAny)
        {
            var hasAny = ExecutePipeline(factReference, pipeline).Any();

            return(wantAny && hasAny || !wantAny && !hasAny);
        }
Esempio n. 10
0
 public Edge(FactReference predecessor, string role, FactReference successor)
 {
     Predecessor = predecessor;
     Role        = role;
     Successor   = successor;
 }
Esempio n. 11
0
 public ImmutableList <Product> Execute(FactReference startReference, FactGraph graph)
 {
     return(Execute(ImmutableList <FactReference> .Empty.Add(startReference), graph));
 }