Ejemplo n.º 1
0
 public void Divisable(EvNum ev)
 {
     if (ev.Num % 5 == 0)
     {
         Console.WriteLine("World (" + ev.Num + ")");
     }
 }
Ejemplo n.º 2
0
 public void Divisable(EvNum ev)
 {
     if (ev.Num % 3 == 0)
     {
         Console.WriteLine("Hello (" + ev.Num + ")");
     }
 }
Ejemplo n.º 3
0
        public void Dispatch(EvNum ev)
        {
            Type        divisableInterface = typeof(IDivisable <>);
            List <Type> dTypes             = Assembly.GetExecutingAssembly().GetTypes()
                                             .Where(t => t.GetInterfaces().Any(i => i.IsDivisableInterface())).ToList();


            foreach (var dType in dTypes)
            {
                Type type   = typeof(IDivisable <>);
                Type iDType = type.MakeGenericType(dType);

                dynamic nextD = _provider.GetService(iDType);
                nextD.Divisable((dynamic)ev);
            }
        }