コード例 #1
0
ファイル: MiniParser.cs プロジェクト: CK-Yong/QboxNext
 /// <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);
     }
 }
コード例 #2
0
 /// <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);
     }
 }
コード例 #3
0
ファイル: MiniParser.cs プロジェクト: CK-Yong/QboxNext
        /// <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);
        }
コード例 #4
0
        /// <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);
        }