Ejemplo n.º 1
0
        // la solution alternative est utilisé interface implementé par 3 classe A B et C

        static void Main(string[] args)
        {
            IMessage mB = new MessageB();
            IMessage mA = new MessageA();
            IMessage mC = new MessageC();

            mA.MyCustomMethod();
            mB.MyCustomMethod();
            mC.MyCustomMethod();
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            var builder = new ContainerBuilder();

            var dataAccess = Assembly.GetEntryAssembly();

            builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies())
            .Where(t => t.Name.EndsWith("Handler"))
            .AsImplementedInterfaces();

            var container = builder.Build();

            var messageHandlers = new MessageHandlerBuilder(container);
            var message         = new MessageA();

            typeof(MessageHandlerBuilder).GetMethod("HandleMessages").MakeGenericMethod(message.GetType()).Invoke(messageHandlers, new object[] { message });

            //messageHandlers.HandleMessages(new MessageA());
        }