예제 #1
0
 public void CreateServiceHost_ServiceTypeIsInterfaceWithServiceContractAttribute_ReturnsServieHostWithProxyAsServiceType()
 {
     var lightInjectServiceHostFactory = new LightInjectServiceHostFactory();
     var serviceHost = lightInjectServiceHostFactory.CreateServiceHost<IServiceWithServiceContractAttribute>();
     var returnedServiceType = serviceHost.Description.ServiceType;
     Assert.IsTrue(typeof(IProxy).IsAssignableFrom(returnedServiceType));
 }
예제 #2
0
        protected ServiceHost StartService <TService>()
        {
            var container = new ServiceContainer();

            container.EnableWcf();
            var serviceHost = new LightInjectServiceHostFactory().CreateServiceHost <TService>("http://localhost:6000/" + typeof(TService).FullName + ".svc");

            serviceHost.Open();
            return(serviceHost);
        }
예제 #3
0
        private ServiceHost StartService <TService>()
        {
            var container = new ServiceContainer();

            container.EnableWcf();

            var serviceHost = new LightInjectServiceHostFactory().CreateServiceHost <TService>("http://localhost:6000");

            serviceHost.Open();
            return(serviceHost);
        }
예제 #4
0
        public void CreateServiceHost_UsingConstructorString_CreatesHost()
        {
            var container = new ServiceContainer();

            container.Register <IService, Service>("MyService");
            container.EnableWcf();
            var serviceHostFactory = new LightInjectServiceHostFactory();

            var serviceHost = serviceHostFactory.CreateServiceHost("MyService", new Uri[] { new Uri("http://localhost:6000/" + "MyService" + ".svc"), });

            Assert.True(typeof(IProxy).IsAssignableFrom(serviceHost.Description.ServiceType));
        }
예제 #5
0
        static void Main(string[] args)
        {
            Console.Title = "WCF Server";

            var serviceContainer = new ServiceContainer();
            serviceContainer.RegisterAssembly(Assembly.GetExecutingAssembly(), (serviceType, implementingType) => serviceType.IsGenericType && (serviceType.GetGenericTypeDefinition() == typeof(IHandleMessages<>) || serviceType.GetGenericTypeDefinition() == typeof(IHandleQueries<,>)));
            serviceContainer.Register<ICustomerService, CustomerService>();
            serviceContainer.Register<IBus>(sf => new Bus(sf.GetAllInstances), new PerContainerLifetime());

            serviceContainer.EnableWcf();

            var serviceHostFactory = new LightInjectServiceHostFactory();
            var url = "http://localhost:8080/customerservice";
            var serviceHost = serviceHostFactory.CreateServiceHost<ICustomerService>(url);
            serviceHost.Open();

            Console.WriteLine("Listening on {0}", url);
            Console.WriteLine("Press 'Enter' to stop the service.");

            Console.ReadLine();

            serviceHost.Close();
        }
예제 #6
0
 public void CreateServiceHost_ServiceTypeIsInterfaceWithoutServiceContractAttribute_ThrowsNotSupportedException()
 {
     var lightInjectServiceHostFactory = new LightInjectServiceHostFactory();
     ExceptionAssert.Throws<NotSupportedException>(() => lightInjectServiceHostFactory.CreateServiceHost<IServiceWithoutServiceContractAttribute>());
 }