private static void EventAggregatorWithContainer() { var mainBuilder = new ContainerBuilder(); mainBuilder.RegisterAssemblyTypes(typeof(Program).Assembly) .AsClosedTypesOf(typeof(DomainEventHandler <>)) .AsImplementedInterfaces() .InstancePerLifetimeScope(); mainBuilder.RegisterType <EventAggregatorContainer>().As <Bases.EventDispacher>(); mainBuilder.RegisterType <EventAggregatorCaller>().As <IEventAggregatorCaller>().InstancePerLifetimeScope(); mainBuilder.RegisterType <EventAggregatorContainer>().As <Bases.EventDispacher>().InstancePerLifetimeScope(); IContainer container = mainBuilder.Build(); IEventAggregatorCaller caller = container.Resolve <IEventAggregatorCaller>(); EventDispacher dispacher = container.Resolve <EventDispacher>(); dispacher.Raise(new AvisadoEstas("Daniel")); caller.Algo(); }
/// <summary> /// </summary> public void Dispatch(object sender) { EventDispacher.Dispatch(sender, this); }