Exemplo n.º 1
0
        public static void TestStringSerialization()
        {
            CommandServiceEventArgs args = new CommandServiceEventArgs();
            string serialized            = Resolve.Serializer.Serialize(args);

            args = Resolve.Serializer.Deserialize <CommandServiceEventArgs>(serialized);

            Assert.That(args.Verb, Is.EqualTo(CommandVerb.Unknown));
            Assert.That(args.Arguments.Count(), Is.EqualTo(0));
        }
Exemplo n.º 2
0
 private static RequestCommandEventArgs ReadCommand(HttpListenerRequest request)
 {
     using (TextReader reader = new StreamReader(request.InputStream, Encoding.UTF8))
     {
         string requestJson = reader.ReadToEnd();
         CommandServiceEventArgs requestArgs = Resolve.Serializer.Deserialize <CommandServiceEventArgs>(requestJson);
         RequestCommandEventArgs args        = new RequestCommandEventArgs(requestArgs);
         return(args);
     }
 }
Exemplo n.º 3
0
        public CommandStatus Dispatch(CommandServiceEventArgs command)
        {
            string json = Resolve.Serializer.Serialize(command);

            while (!New <IRuntimeEnvironment>().IsFirstInstanceReady(TimeSpan.FromMilliseconds(100)))
            {
            }

            WebRequest request = HttpWebRequest.Create(HttpRequestServer.Url);

            try
            {
                return(DoRequestInternal("POST", json, request));
            }
            catch (WebException wex)
            {
                if (wex.Status == WebExceptionStatus.ConnectFailure)
                {
                    New <IReport>().Exception(wex);
                    return(CommandStatus.NoResponse);
                }
                throw;
            }
        }
Exemplo n.º 4
0
 public void AcceptRequest(CommandServiceEventArgs command)
 {
     OnRequest(new RequestCommandEventArgs(command));
 }
 public CommandStatus Dispatch(CommandServiceEventArgs command)
 {
     return(FakeDispatcher(command));
 }