コード例 #1
0
        public WcfServer(AutofacServiceHostFactory factory, AutofacWebServiceHostFactory webFactory, ZetboxConfig config)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }
            if (webFactory == null)
            {
                throw new ArgumentNullException("webFactory");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            _defaultConfig = config;

            _mainHost = factory.CreateServiceHost(typeof(ZetboxService).AssemblyQualifiedName, new Uri[] { });
            _mainHost.UnknownMessageReceived += new EventHandler <UnknownMessageReceivedEventArgs>(host_UnknownMessageReceived);
            _mainHost.Faulted += host_Faulted;
            _mainHost.Closed  += host_Closed;
            _mainHost.Opened  += host_Opened;

            _bootstrapperHost = webFactory.CreateServiceHost(typeof(BootstrapperService).AssemblyQualifiedName, new Uri[] { });
        }
コード例 #2
0
        public void DetectsUnknownImplementationTypes()
        {
            var builder = new ContainerBuilder();

            builder.Register <IServiceProvider>(c => (Container) new ContainerBuilder().Build()).Named <object>("service");
            TestWithHostedContainer(builder.Build(), () =>
            {
                var factory = new AutofacServiceHostFactory();
                var host    = factory.CreateServiceHost("service", DummyEndpoints);
            });
        }
コード例 #3
0
        public void HostsTypedServicesAsServices()
        {
            var builder = new ContainerBuilder();

            builder.Register(c => "Test").As <object>();
            TestWithHostedContainer(builder.Build(), () =>
            {
                var factory = new AutofacServiceHostFactory();
                var host    = factory.CreateServiceHost(typeof(object).FullName, DummyEndpoints);
                Assert.IsNotNull(host);
                Assert.AreEqual(typeof(string), host.Description.ServiceType);
            });
        }
コード例 #4
0
        public void HostsKeyedServices()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <object>().Named <object>("service");
            TestWithHostedContainer(builder.Build(), () =>
            {
                var factory = new AutofacServiceHostFactory();
                var host    = factory.CreateServiceHost("service", DummyEndpoints);
                Assert.AreEqual(typeof(object), host.Description.ServiceType);
                Assert.IsNotNull(host);
            });
        }