Beispiel #1
0
        HttpResponseMessage AddPipe(string name, RestMSPipeNew pipe)
        {
            var newPipeCommand = new AddPipeCommand(name, pipe.Type, pipe.Title);

            commandProcessor.Send(newPipeCommand);

            return(BuildDomainItemCreatedReponse(name));
        }
Beispiel #2
0
        /// <summary>
        /// Parses the specified body.
        /// </summary>
        /// <param name="body">The body.</param>
        /// <returns>Tuple&lt;ParseResult, RestMSFeed, RestMSPipeNew&gt;.</returns>
        public Tuple <ParseResult, RestMSFeed, RestMSPipeNew> Parse(string body)
        {
            RestMSPipeNew pipeNew = null;
            RestMSFeed    feedNew = null;

            if (TryParseNewPipe(body, out pipeNew))
            {
                return(new Tuple <ParseResult, RestMSFeed, RestMSPipeNew>(ParseResult.NewPipe, feedNew, pipeNew));
            }
            else if (TryParseNewFeed(body, out feedNew))
            {
                return(new Tuple <ParseResult, RestMSFeed, RestMSPipeNew>(ParseResult.NewFeed, feedNew, pipeNew));
            }

            return(new Tuple <ParseResult, RestMSFeed, RestMSPipeNew>(ParseResult.Failed, feedNew, pipeNew));
        }
Beispiel #3
0
        private bool TryParseNewPipe(string body, out RestMSPipeNew newPipe)
        {
            MemoryStream ms = null;

            try
            {
                ms      = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(body));
                newPipe = (RestMSPipeNew)_pipeDeserializer.Deserialize(ms);
                return(true);
            }
            catch (Exception)
            {
                newPipe = null;
                return(false);
            }
            finally
            {
                if (ms != null)
                {
                    ms.Dispose();
                }
            }
        }