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