public static void View <T>(this IViewableSet <T> me, Lifetime lifetime, Action <Lifetime, T> handler) { var lifetimes = new Dictionary <T, LifetimeDefinition>(); me.Advise(lifetime, (kind, value) => { switch (kind) { case AddRemove.Add: var def = Lifetime.Define(lifetime); lifetimes[value] = def; handler(def.Lifetime, value); break; case AddRemove.Remove: def = lifetimes[value]; lifetimes.Remove(value); def.Terminate(); break; default: throw new ArgumentOutOfRangeException($"illegal enum value: {kind}"); } }); }
public void Advise(Lifetime lifetime, Action <SetEvent <T> > handler) { if (IsBound) { AssertThreading(); } using (UsingDebugInfo()) mySet.Advise(lifetime, handler); }
public static void Advise <T>(this IViewableSet <T> me, Lifetime lifetime, Action <AddRemove, T> handler) { me.Advise(lifetime, e => handler(e.Kind, e.Value)); }
public void Advise(Lifetime lifetime, Action <SetEvent <T> > handler) { myBackingSet.Advise(lifetime, handler); }