Example #1
0
        static void Main(string[] args)
        {
            CriteraDelegate exampleDelegate1 = new CriteraDelegate(ExecuteCritera1);
            CriteraDelegate exampleDelegate2 = new CriteraDelegate(ExecuteCritera2);
            CriteraManager  manager          = new CriteraManager();

            manager.RegisterCritera(typeof(InterfaceB1), exampleDelegate2);
            manager.RegisterCritera(typeof(InterfaceB2), exampleDelegate2);
            manager.RegisterCritera(typeof(InterfaceC), exampleDelegate1);
            ClassB1 b1 = new ClassB1();
            ClassB2 b2 = new ClassB2();
            ClassC  c  = new ClassC();

            manager.Execute(b1, "Should execute delegate 2");
            manager.Execute(b2, "Should execute delegate 2");
            manager.Execute(c, "Should execute delegate 1");
        }
 public void RegisterCritera(Type type, CriteraDelegate del)
 {
     criterian[type] = del;
 }