コード例 #1
0
        public (DeserializerCache, Func <Fact, Emitter, object>) GetDeserializer(Type type)
        {
            DeserializerCache after = this;

            if (!deserializerByType.TryGetValue(type, out var deserializer))
            {
                deserializer = Deserialize(type).Compile();
                after        = new DeserializerCache(deserializerByType.Add(type, deserializer));
            }
            return(after, (fact, emitter) => deserializer.DynamicInvoke(fact, emitter));
        }
コード例 #2
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);
        }
コード例 #3
0
 public Emitter(FactGraph graph, DeserializerCache deserializerCache, IWatchContext?watchContext = null)
 {
     this.graph        = graph;
     DeserializerCache = deserializerCache;
     WatchContext      = watchContext;
 }