HttpResponseMessage AddPipe(string name, RestMSPipeNew pipe) { var newPipeCommand = new AddPipeCommand(name, pipe.Type, pipe.Title); commandProcessor.Send(newPipeCommand); return(BuildDomainItemCreatedReponse(name)); }
/// <summary> /// Parses the specified body. /// </summary> /// <param name="body">The body.</param> /// <returns>Tuple<ParseResult, RestMSFeed, RestMSPipeNew>.</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)); }
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(); } } }