/// <summary> /// 开启定时任务操作 /// </summary> public void StartTimerQuartzJobs() { if (_sched == null) { ISchedulerFactory sf = new StdSchedulerFactory(); //执行者 _sched = sf.GetScheduler(); } var msg = string.Format("{0} => {1}", DateTime.Now, "正在启动定时任务..."); SafeSetText(msg, richTimerPush, false); //容器处理 var creaters = WindsorHelper.ResolveAll <JobCreater>(); foreach (var creater in creaters) { if (creater.CronExpression == "false") { continue; } msg = string.Format("{0} => {1}", DateTime.Now, "启动任务:" + creater.JobType.FullName + "..."); SafeSetText(msg, richTimerPush, false); //添加定时任务 AddJobToSchedule(creater.JobType, creater.CronExpression); } _sched.Start(); msg = string.Format("{0} => {1}", DateTime.Now, "定时任务启动成功..."); SafeSetText(msg, richTimerPush, false); }
public void ResolveType_ContainerWithoutTypeRegistered() { var helper = new WindsorHelper(); var container = new WindsorContainer(); ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface))); }
public void ResolveType_InvalidContainer() { var helper = new WindsorHelper(); var container = new object(); ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface))); }
public void IsValidContainer_ValidContainer() { var helper = new WindsorHelper(); var container = new WindsorContainer(); Assert.IsTrue(helper.IsValidContainer(container)); }
public void GetRegistrationInfo_InterfaceTypeNull() { var helper = new WindsorHelper(); var container = new WindsorContainer(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.GetRegistrationInfo(container, null)); }
public void GetRegistrationInfo_InvalidContainer() { var helper = new WindsorHelper(); var container = new object(); ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.GetRegistrationInfo(container, typeof(ITestInterface))); }
public void RegisterInstance_InvalidContainer() { var helper = new WindsorHelper(); var container = new object(); ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.RegisterInstance(container, typeof(ITestInterface), new TestClass1())); }
public void GetRegistrationInfo_ContainerWithoutTypeRegistered() { var helper = new WindsorHelper(); var container = new WindsorContainer(); Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface))); }
public void RegisterInstance_InstanceNull() { var helper = new WindsorHelper(); var container = new WindsorContainer(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.RegisterInstance(container, typeof(ITestInterface), null)); }
public void RegisterInstance_InterfaceTypeNull() { var helper = new WindsorHelper(); var container = new WindsorContainer(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.RegisterInstance(container, null, new TestClass1())); }
public void RegisterType_InvalidContainer() { var helper = new WindsorHelper(); var container = new object(); ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.RegisterType(container, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton)); }
public void RegisterType_ImplementingTypeNull() { var helper = new WindsorHelper(); var container = new WindsorContainer(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.RegisterType(container, typeof(ITestInterface), null, RegistrationType.Singleton)); }
public void IsValidContainer_InvalidContainer() { var helper = new WindsorHelper(); var container = new object(); Assert.IsFalse(helper.IsValidContainer(container)); }
public void ResolveType_InterfaceTypeNull() { var helper = new WindsorHelper(); var container = new WindsorContainer(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.ResolveType(container, null)); }
public void RegisterType_Valid() { var helper = new WindsorHelper(); var container = new WindsorContainer(); Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface))); helper.RegisterType(container, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton); Assert.IsTrue(container.Resolve <ITestInterface>() != null); }
public void GetRegistrationInfo_ContainerWithTransientTypeRegistered() { var helper = new WindsorHelper(); var container = new WindsorContainer(); container.Register(new IRegistration[] { new ComponentRegistration <ITestInterface>().ImplementedBy <TestClass1>().LifestyleTransient() }); var registrationInfo = helper.GetRegistrationInfo(container, typeof(ITestInterface)); Assert.AreEqual(typeof(ITestInterface), registrationInfo.DeclaringType); Assert.AreEqual(RegistrationType.Transient, registrationInfo.RegistrationType); }
public static void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } ); config.DependencyResolver = WindsorHelper.GetDependencyResolver(); }
public void RegisterInstance_Valid() { var helper = new WindsorHelper(); var instance = new TestClass1() { Name = "test" }; var container = new WindsorContainer(); Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface))); helper.RegisterInstance(container, typeof(ITestInterface), instance); Assert.IsTrue(container.Resolve <ITestInterface>() != null); Assert.AreEqual(instance, container.Resolve <ITestInterface>()); }
private void FormQuartz_Load(object sender, EventArgs e) { //容器处理 var creaters = WindsorHelper.ResolveAll <JobCreater>(); var panel = new Panel { Dock = DockStyle.Fill, AutoScroll = true, Width = splitContainer1.Panel1.Width }; var index = 0; foreach (var creater in creaters) { var button = new Button(); if (creater.CronExpression == "false") { button.Text = DoText + LeftImportText + creater.JobType.Name + RightImportText; } else { button.Text = DoTextByScheduler + LeftImportText + creater.JobType.Name + RightImportText; } button.Tag = creater; button.Click += button_Click; button.Width = panel.Width - 30; button.Left = 10; button.Top = 5 + (index * (5 + button.Height)); panel.Controls.Add(button); index++; } //添加到Panel splitContainer1.Panel1.Controls.Add(panel); //开始显示消息 MessageCenter.PushMessage += MessageCenter_PushMessage; }
public void ResolveType_Transient() { var helper = new WindsorHelper(); var container = new WindsorContainer(); container.Register(new IRegistration[] { new ComponentRegistration <ITestInterface>().ImplementedBy <TestClass1>().LifestyleTransient() }); var resolvedInstance1 = helper.ResolveType(container, typeof(ITestInterface)); Assert.IsNotNull(resolvedInstance1); Assert.IsInstanceOfType(resolvedInstance1, typeof(TestClass1)); var resolvedInstance2 = helper.ResolveType(container, typeof(ITestInterface)); Assert.IsNotNull(resolvedInstance2); Assert.IsInstanceOfType(resolvedInstance2, typeof(TestClass1)); Assert.IsFalse(ReferenceEquals(resolvedInstance1, resolvedInstance2)); }
public void RegisterInstance_ContainerNull() { var helper = new WindsorHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.RegisterInstance(null, typeof(ITestInterface), new TestClass1())); }
public void IsValidContainer_Null() { var helper = new WindsorHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.IsValidContainer(null)); }
public void ResolveType_ContainerNull() { var helper = new WindsorHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.ResolveType(null, typeof(ITestInterface))); }
public void GetRegistrationInfo_ContainerNull() { var helper = new WindsorHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.GetRegistrationInfo(null, typeof(ITestInterface))); }
public void RegisterType_ContainerNull() { var helper = new WindsorHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.RegisterType(null, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton)); }