/// <summary> /// Can the message be parsed? /// </summary> /// <remarks> /// This is checked by actually parsing the message, so only use in contexts that are not performance critical. /// </remarks> public bool CanParse(string source) { BaseParseResult = new MiniParseResult(); try { Parser = new StringParser(source); DoParse(); return(true); } catch { return(false); } }
/// <summary> /// Can the message be parsed? /// </summary> /// <remarks> /// This is checked by actually parsing the message, so only use in contexts that are not performance critical. /// </remarks> public bool CanParse(string source) { BaseParseResult = new MiniParseResult(); try { Reader = _protocolReaderFactory.Create(source.AsMemory()); DoParse(); return(true); } catch { return(false); } }
/// <inheritdoc /> public BaseParseResult Parse(string source) { Log.LogTrace("Enter"); BaseParseResult = new MiniParseResult(); try { Parser = new StringParser(source); DoParse(); } catch (Exception e) { BaseParseResult = new ErrorParseResult(BaseParseResult) { Error = String.Format("Source: {0}{1}Error: {2} {3}", source, Environment.NewLine, e.Message, e.InnerException == null ? "" : e.InnerException.Message) }; Log.LogError(e, "{0} (source = {1})", e.Message, source); } Log.LogTrace("Return"); return(BaseParseResult); }
/// <inheritdoc /> public BaseParseResult Parse(string source) { _logger.LogTrace("Enter"); BaseParseResult = new MiniParseResult(); try { Reader = _protocolReaderFactory.Create(source.AsMemory()); DoParse(); } catch (Exception e) { BaseParseResult = new ErrorParseResult(BaseParseResult) { Error = String.Format("Source: {0}{1}Error: {2} {3}", source, Environment.NewLine, e.Message, e.InnerException == null ? "" : e.InnerException.Message) }; _logger.LogError(e, "{0} (source = {1})", e.Message, source); } _logger.LogTrace("Return"); return(BaseParseResult); }