/// <summary> /// 使用强制检查Event的是存在没有参数的构造函数 /// </summary> /// <param name="ignoreTypes">忽略的对象</param> /// <param name="startup"></param> /// <returns></returns> public static ApplicationStartup UseForceCheckCommandEvenWithNoParamaterCtor(this ApplicationStartup startup, IEnumerable <Type> ignoreTypes = null) { if (startup.Items.ContainsKey("UseForceCheckEventHandlerCtor")) { return(startup); } startup.RegisterStartService(int.MaxValue, (x) => { x.ProcessType(new[] { new CommandStartupService.CommandNoCtorParamaterProcessor(ignoreTypes ?? Type.EmptyTypes) }); }); startup.RegisterStartService(int.MaxValue, (x) => { x.ProcessType(new[] { new EventStartupService.EventNoCtorParamaterProcessor(ignoreTypes ?? Type.EmptyTypes) }); }); return(startup); }
/// <summary> /// 使用强制检查EventHandler的构造函数是否在IoC可以构造出来 /// </summary> /// <param name="ignoreTypes">忽略的对象</param> /// <param name="startup"></param> /// <returns></returns> public static ApplicationStartup UseForceCheckEventHandlerCtor(this ApplicationStartup startup, IEnumerable <Type> ignoreTypes) { if (startup.Items.ContainsKey("UseForceCheckEventHandlerCtor")) { return(startup); } startup.RegisterStartService(true, (x) => { x.ProcessType(new[] { new EventStartupService.EventHandlerCtorParameterProcessor(ignoreTypes ?? Type.EmptyTypes) }); }); return(startup); }
/// <summary> /// 使用强制聚合根有Handle方法但没有实现<see cref="Never.Domains.IHandle{TEvent}"/>接口 /// </summary> /// <param name="startup">The startup.</param> /// <returns></returns> public static ApplicationStartup UseForceCheckAggregateRootImplIHandle(this ApplicationStartup startup) { if (startup.Items.ContainsKey("UseForceCheckAggregateRootImplIHandle")) { return(startup); } startup.RegisterStartService(new AggregateRootIHandleStartService()); return(startup); }
/// <summary> /// 使用强制检查事件是否带上了<see cref="Never.EventStreams.EventAppDomainStartupService"/>特性 /// </summary> /// <param name="startup">The startup.</param> /// <returns></returns> public static ApplicationStartup UseForceCheckEventAppDomainAttribute(this ApplicationStartup startup) { if (startup.Items.ContainsKey("UseForceCheckEventAppDomainAttribute")) { return(startup); } startup.RegisterStartService(new EventAppDomainStartupService()); return(startup); }
/// <summary> /// 注入commandhanler和eventhandler /// </summary> /// <param name="startup"></param> /// <param name="lifeStyle"></param> /// <returns></returns> public static ApplicationStartup UseInjectingCommandHandlerEventHandler(this ApplicationStartup startup, ComponentLifeStyle lifeStyle) { if (startup.Items.ContainsKey("UseInjectCommandHandlerEventHandler")) { return(startup); } startup.RegisterStartService(new Never.Domains.StartupService(lifeStyle)); return(startup); }
/// <summary> /// 【服务端】开户处理远程调用 /// </summary> /// <param name="startup"></param> /// <param name="handler"></param> /// <param name="listeningEndPoint"></param> /// <returns></returns> public static ApplicationStartup UseHttpRemoteResponseHandler(this ApplicationStartup startup, System.Net.EndPoint listeningEndPoint, Remoting.IResponseHandler handler) { if (startup.Items.ContainsKey("UseHttpRemoteResponseHandler")) { return(startup); } var service = new Remoting.ServerRequestHandler(listeningEndPoint, handler, new Remoting.Http.Protocol()); startup.RegisterStartService(20, (x) => { service.Startup(); }); startup.Items["UseHttpRemoteResponseHandler"] = "t"; return(startup); }
/// <summary> /// 使用强制检查MessageSubscriber的构造函数是否在IoC可以构造出来 /// </summary> /// <param name="ignoreTypes">忽略的对象</param> /// <param name="startup"></param> /// <returns></returns> public static ApplicationStartup UseForceCheckMessageSubscriberCtor(this ApplicationStartup startup, IEnumerable <Type> ignoreTypes) { if (startup.Items.ContainsKey("UseForceCheckMessageSubscriberCtor")) { return(startup); } startup.RegisterStartService(true, (x) => { x.ProcessType(new[] { new MessageStartupService.MessageHandlerCtorProcessor(ignoreTypes) }); }); return(startup); }
/// <summary> /// 【客户端】开户请求远程调用 /// </summary> /// <param name="startup"></param> /// <param name="key"></param> /// <param name="serverEndPoint"></param> /// <returns></returns> public static ApplicationStartup UseHttpRemoteRequestHandler(this ApplicationStartup startup, string key, System.Net.EndPoint serverEndPoint) { if (startup.Items.ContainsKey(string.Concat("UseHttpRemoteRequestHandler", key))) { return(startup); } var client = new Remoting.ClientRequestHadler(serverEndPoint, new Remoting.Http.Protocol()); startup.ServiceRegister.RegisterInstance(client, typeof(Remoting.IRequestHandler), key); startup.RegisterStartService(true, (x) => { client.Startup(); }); startup.Items[string.Concat("UseHttpRemoteRequestHandler", key)] = "t"; return(startup); }
/// <summary> /// 启用发布订阅模式,生命周期通常声明为单例 /// </summary> /// <typeparam name="TMessageContext">事件上下文</typeparam> /// <param name="startup">程序宿主环境配置服务</param> /// <param name="lifeStyle">生命周期</param> /// <returns></returns> public static ApplicationStartup UsePublishSubscribeBus <TMessageContext>(this ApplicationStartup startup, ComponentLifeStyle lifeStyle) where TMessageContext : IMessageContext { if (startup.ServiceRegister == null) { return(startup); } if (startup.Items.ContainsKey("UsePublishSubscribeBus")) { return(startup); } /*注册发布事件*/ startup.ServiceRegister.RegisterType(typeof(MessagePublisher), typeof(IMessagePublisher), string.Empty, ComponentLifeStyle.Singleton); startup.ServiceRegister.RegisterType(typeof(TMessageContext), typeof(IMessageContext), string.Empty, ComponentLifeStyle.Transient); startup.RegisterStartService(new Never.Messages.StartupService(lifeStyle)); startup.Items["UsePublishSubscribeBus"] = "t"; return(startup); }
/// <summary> /// 在sampleioc中自动使用属性发现注入 /// </summary> /// <param name="startup"></param> /// <param name="providers"></param> /// <returns></returns> public static ApplicationStartup UseAutoInjectingAttributeUsingIoC(this ApplicationStartup startup, IAutoInjectingEnvironmentProvider[] providers) { startup.RegisterStartService(new AutoInjectingStartupService(providers)); return(startup); }