예제 #1
0
        private static void StartServerAndWaitForKey(Uri uri, Type type)
        {
            if (DomainServicesSection.Current.Endpoints.Count == 1)
            {
                DomainServicesSection.Current.Endpoints.Add(
                    new ProviderSettings("soap", typeof(SoapXmlEndpointFactory).AssemblyQualifiedName));
                DomainServicesSection.Current.Endpoints.Add(
                    new ProviderSettings("json", typeof(JsonEndpointFactory).AssemblyQualifiedName));
            }

            using (var host = new DomainServiceHost(type, uri))
            {
                //other relevent code to configure host's end point etc
                if (host.Description.Behaviors.Contains(typeof(AspNetCompatibilityRequirementsAttribute)))
                {
                    var compatibilityRequirementsAttribute = host.Description.Behaviors[typeof(AspNetCompatibilityRequirementsAttribute)] as AspNetCompatibilityRequirementsAttribute;
                    compatibilityRequirementsAttribute.RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed;
                }

                host.Open();

                Console.WriteLine($"DomainService {type.Name} running at {uri}");
                Console.WriteLine("Press ENTER to exit");
                Console.ReadLine();
                host.Close();
            }
        }
예제 #2
0
 public void Stop()
 {
     _host.Close();
 }