public void ResolveTest() { using (var container = new WindsorContainer()) { var resolver = new StatelessServiceResolver(container.Kernel, typeof(TestStatelessService)) { }; var context = MockStatelessServiceContextFactory.Default; Assert.Throws <ComponentNotFoundException>(() => resolver.Resolve(context)); container.Register(Component.For <TestStatelessService>().LifestyleTransient()); var service = resolver.Resolve(context); Assert.NotNull(service); Assert.IsType <TestStatelessService>(service); resolver = new StatelessServiceResolver(container.Kernel, typeof(TestStatelessService)); service = resolver.Resolve(context); Assert.NotNull(service); Assert.IsType <TestStatelessService>(service); } }
public void RegisterComponent(IKernel kernel, IHandler handler) { var model = handler.ComponentModel; var serviceResolver = new StatelessServiceResolver(kernel, model.Implementation); ServiceRuntime.RegisterServiceAsync( handler.GetProperty <string>(FacilityConstants.ServiceTypeNameKey), serviceResolver.Resolve) .GetAwaiter() .GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, handler.ComponentModel.Implementation.Name); }