コード例 #1
0
ファイル: ConfigurationHelper.cs プロジェクト: wortexx/zaz
        public static CommandsService CreateService(ServerConfiguration configuration)
        {
            var context = new ServerContext(configuration.Registry, configuration.Broker, configuration.StateProvider);

            var service = new CommandsService(context);
            return service;
        }
コード例 #2
0
 public void Given_command_server_runnig()
 {
     var instance = new CommandsService();
     var config = ConfigurationHelper.CreateConfiguration(instance);
     _host = new HttpServiceHost(typeof(CommandsService), config, new Uri(URL));
     _host.Open();
 }
コード例 #3
0
 public void Given_command_server_runnig()
 {
     var instance = new CommandsService(new ServerContext
     (
         registry: new ReflectionCommandRegistry(typeof(__SampleCommandsMarker).Assembly),
         broker: new LongCommandBroker()
     ));
     var config = ConfigurationHelper.CreateConfiguration(instance);
     _host = new HttpServiceHost(typeof(CommandsService), config, new Uri(URL));
     _host.Open();
 }
コード例 #4
0
ファイル: ConfigurationHelper.cs プロジェクト: wortexx/zaz
        //[Obsolete("Use CreateServiceConfiguration")]
        public static HttpConfiguration CreateConfiguration(CommandsService service)
        {
            var config = new HttpConfiguration();
            config.CreateInstance = (t, c, m) => service;

            config.Formatters.Insert(0, new JsonNetFormatter());
            config.MaxReceivedMessageSize = 16777216;
            config.MaxBufferSize = 16777216;

            return config;
        }
コード例 #5
0
 public void Given_service_by_default()
 {
     _broker = new CommandBrokerStub();
     var service = new CommandsService(new ServerContext(broker: _broker));
     var cmdKey = typeof (FooCommand).FullName;
     var cmdContent = new StringContent("Zaz-Command-Id=" + cmdKey + "&Value1=Foo");
     cmdContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
     var cmdMessage = new HttpRequestMessage
         {
             Content = cmdContent
         };
     _result = service.PostLegacy(cmdMessage);
 }
コード例 #6
0
 public void Given_service_by_default()
 {
     _broker = new CommandBrokerStub();
     var service = new CommandsService(new ServerContext (broker: _broker ));
     var cmdKey = typeof (FooCommand).FullName;
     var cmdData = new JObject();
     cmdData.Add("Value1", "Foo");
     _result = service.Post(new PostCommandRequest
     {
         Key = cmdKey,
         Command = cmdData
     });
 }
        public void Given_command_server_runnig()
        {
            var instance = new CommandsService(new ServerContext(
                registry: new FooCommandRegistry(),
                broker: new DelegatingCommandBroker((cmd, ctx) => {
                    return Task.Factory.StartNew(() =>
                    {
                    });
                })));

            var config = ConfigurationHelper.CreateConfiguration(instance);

            SimpleBasicAuthenticationHandler.Configure(config, cred => false);

            _host = new HttpServiceHost(typeof(CommandsService), config, new Uri(URL));
            _host.Open();
        }
コード例 #8
0
        public void Given_command_server_runnig()
        {
            var instance = new CommandsService(new ServerContext
            (
                registry: new FooCommandRegistry(),
                broker: new DelegatingCommandBroker((cmd, ctx) =>
                {
                    _postedCommand = cmd;
                    _ctx = ctx;

                    return Task.Factory.StartNew(() => {});
                })
            ));
            var config = ConfigurationHelper.CreateConfiguration(instance);

            SimpleBasicAuthenticationHandler.Configure(config, cred => cred.UserName == "supr" && cred.Password == "booper");

            _host = new HttpServiceHost(typeof(CommandsService), config, new Uri(URL));
            _host.Open();

            // Client side

            var bus = new CommandBus(URL, new Client.Avanced.ZazConfiguration
            {
                ConfigureHttp = h =>
                {
                    h.Credentials = new NetworkCredential("supr", "booper");
                }
            });
            bus.Post(new FooCommand
            {
                Message = "Hello world"
            });

            // Close host
            _host.Close();
        }
コード例 #9
0
 public void Given_service_by_default()
 {
     var service = new CommandsService(new ServerContext( broker: new CommandBrokerStub() ));
     _result = service.Get("");
 }