public IDisposable AddTemporalObserver <T>(ITemporalObserver <T> observer, string token, string description = null, int priority = TemporalContextManager.NewTokenPriority) { ITemporalStream stream = m_streams.GetOrAdd(token, _token => { stream = new TemporalStream <T>(description); stream.NoObservers += () => { ITemporalStream forNull; m_streams.TryRemove(token, out forNull); }; return(stream); }); TemporalContext <T> ctx = new TemporalContext <T>((ITemporalValueSource <T>)stream, observer, priority); return(stream.Subscribe(new TemporalContextHelper <T>(ctx, this))); }
public TemporalContextHelper(TemporalContext <T> context, TemporalContextManager manager) { m_context = context; m_manager = manager; m_manager.AddTemporalValue("Contexts", new TemporalValue <object>(DateTime.Now.Ticks, m_context)); }