static void HostWithHttpsEndpoint()
        {
            var repository = new ToDoMemoryRepository();
            repository.Add(new ToDo("Must learn HTTP better"));
            var instance = new TodoResource(repository);
            using (var host = new HttpServiceHost(instance, "http://localhost:8080/todo"))
            {
                
                host.AddServiceEndpoint(typeof(TodoResource), new HttpBinding(), "http://localhost:8080/todo");

                var binding = new HttpBinding(HttpBindingSecurityMode.Transport);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                host.AddServiceEndpoint(typeof(TodoResource), binding, "https://localhost:8435/todo");
                //host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser,StoreName.My,X509FindType.FindBySubjectName, "gaviao");
                host.Open();
                ShowEndpointsOf(host);
                WaitForKey();
            }
        }
 static void HostWithHttpServiceHost()
 {
     var instance = new TodoResource(new ToDoMemoryRepository());
     using (var host = new HttpServiceHost(instance, "http://localhost:8080/todo"))
     {
         host.AddServiceEndpoint(typeof(TodoResource), new HttpBinding(), "http://localhost:8080/todo2");
         host.Open();
         ShowEndpointsOf(host);
         WaitForKey();
     }
 }
 public static void Run()
 {
     using (var host = new HttpServiceHost(typeof(TheService), new string[0]))
     {
         var mb = new HttpMemoryBinding();
         var ep = host.AddServiceEndpoint(typeof (TheService), mb, "http://dummy-http-scheme-uri");
         foreach (var op in ep.Contract.Operations)
         {
             op.Behaviors.Find<OperationBehaviorAttribute>().AutoDisposeParameters = false;
         }
         host.Open();
         Console.WriteLine("Host opened at {0}", host.Description.Endpoints[0].Address);
         var client = new HttpClient(mb.GetHttpMemoryHandler());
         // Yes, it must be async. Apparently, sync is not supported with the memory channel
         var aresp = client.GetAsync("http://another-dummy-http-scheme-uri/hello");
         Console.WriteLine(aresp.Result.Content.ReadAsStringAsync().Result);
         Console.ReadKey();
     }
 }