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)); }
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 Emitter(FactGraph graph, DeserializerCache deserializerCache, IWatchContext?watchContext = null) { this.graph = graph; DeserializerCache = deserializerCache; WatchContext = watchContext; }