コード例 #1
0
 public void ServiceHost_Explicit_Add_Endpoint_Without_Behavior()
 {
     ContractDescription cd = ContractDescription.GetContract(typeof(LocalCustomerService));
     HttpServiceHost host = new HttpServiceHost(typeof(LocalCustomerService), new Uri("http://localhost"));
     HttpEndpoint endpoint = new HttpEndpoint(cd, new EndpointAddress("http://somehost"));
     endpoint.Behaviors.Clear();
     Assert.AreEqual(0, endpoint.Behaviors.Count, "Expected no behaviors by default");
     host.Description.Endpoints.Add(endpoint);
     host.Open();
     Assert.AreEqual(1, endpoint.Behaviors.OfType<HttpBehavior>().Count(), "Expected open to add behavior");
 }
 protected override void OnConfigureEndpoint(HttpEndpoint endpoint);
コード例 #3
0
ファイル: HttpServiceHost.cs プロジェクト: nuxleus/WCFWeb
        private ServiceEndpoint GenerateDefaultServiceEndpoint(Uri baseAddress)
        {
            if (this.ImplementedContracts.Count != 1)
            {
                throw new InvalidOperationException(SR.DefaultEndpointsServiceWithMultipleContracts(this.Description.Name, httpServiceHostTypeName));
            }

            ContractDescription contractDescription = this.ImplementedContracts.Values.First();

            HttpEndpoint endpoint = new HttpEndpoint(contractDescription, new EndpointAddress(baseAddress));
            endpoint.MessageHandlerFactory = this.MessageHandlerFactory;
            endpoint.OperationHandlerFactory = this.OperationHandlerFactory;

            return endpoint;
        }