Ejemplo n.º 1
0
        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}");
                }
            });
        }
Ejemplo n.º 2
0
Archivo: RdSet.cs Proyecto: yvvan/rd
 public void Advise(Lifetime lifetime, Action <SetEvent <T> > handler)
 {
     if (IsBound)
     {
         AssertThreading();
     }
     using (UsingDebugInfo())
         mySet.Advise(lifetime, handler);
 }
Ejemplo n.º 3
0
 public static void Advise <T>(this IViewableSet <T> me, Lifetime lifetime, Action <AddRemove, T> handler)
 {
     me.Advise(lifetime, e => handler(e.Kind, e.Value));
 }
Ejemplo n.º 4
0
 public void Advise(Lifetime lifetime, Action <SetEvent <T> > handler)
 {
     myBackingSet.Advise(lifetime, handler);
 }