예제 #1
0
 public void Divisable(EvNum ev)
 {
     if (ev.Num % 5 == 0)
     {
         Console.WriteLine("World (" + ev.Num + ")");
     }
 }
예제 #2
0
 public void Divisable(EvNum ev)
 {
     if (ev.Num % 3 == 0)
     {
         Console.WriteLine("Hello (" + ev.Num + ")");
     }
 }
예제 #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);
            }
        }