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();
            }
        }
Exemple #2
0
        public void Start()
        {
            _host = new DomainServiceHost(typeof(CityDomainService), _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();
            switch (DomainClient)
            {
            case DomainClientType.HttpBinary:
                throw new NotImplementedException();
                //DomainContext.DomainClientFactory = new OpenRiaServices.Client.PortableWeb.WebApiDomainClientFactory();
                break;

            case DomainClientType.HttpBinaryWinHttp:
                throw new NotImplementedException();

                /*DomainContext.DomainClientFactory = new OpenRiaServices.Client.PortableWeb.WebApiDomainClientFactory()
                 * {
                 *  HttpClientHandler = new WinHttpHandler() { }
                 * };*/
                break;

            case DomainClientType.WcfBinary:
                DomainContext.DomainClientFactory = new OpenRiaServices.Client.Web.WebDomainClientFactory();
                break;

            default:
                throw new NotImplementedException();
            }

            _ctx = new CityDomainContext(_clientUri);
            CityDomainService.GetCitiesResult = CreateValidCities(NumEntities).ToList();

            _ctx.LoadAsync(_ctx.GetCitiesQuery()).GetAwaiter().GetResult();
        }