コード例 #1
0
        public static OsInfo MatchResultToOsInfo(byte[] resultBytes, Encoding encode)
        {
            string result  = GetResultFromInterval(resultBytes, encode);
            string pattern = @"^(?<ShellDir>.*?)\t(?<Platform>.*?)\t(?<CurrentUser>.*?)\t(?<DirSeparators>.*?)$";
            Regex  regex   = new Regex(pattern, RegexOptions.Singleline);
            Match  m       = regex.Match(result);

            if (!m.Success)
            {
                throw new ResponseCustomException("匹配返回结果", "匹配失败", result);
            }
            else
            {
                OsInfo info = new OsInfo();
                info.ShellDir      = m.Groups["ShellDir"].Value;
                info.Platform      = m.Groups["Platform"].Value;
                info.CurrentUser   = m.Groups["CurrentUser"].Value;
                info.DirSeparators = m.Groups["DirSeparators"].Value;
                return(info);
            }
        }
コード例 #2
0
ファイル: ResultMatch.cs プロジェクト: GHubgenius/Altman
 public static OsInfo MatchResultToOsInfo(byte[] resultBytes, Encoding encode)
 {
     string result = GetResultFromInterval(resultBytes, encode);
     string pattern = @"^(?<ShellDir>.*?)\t(?<Platform>.*?)\t(?<CurrentUser>.*?)\t(?<DirSeparators>.*?)$";
     Regex regex = new Regex(pattern, RegexOptions.Singleline);
     Match m = regex.Match(result);
     if (!m.Success)
     {
         throw new ResponseCustomException("匹配返回结果", "匹配失败", result);
     }
     else
     {
         OsInfo info = new OsInfo();
         info.ShellDir = m.Groups["ShellDir"].Value;
         info.Platform = m.Groups["Platform"].Value;
         info.CurrentUser = m.Groups["CurrentUser"].Value;
         info.DirSeparators = m.Groups["DirSeparators"].Value;
         return info;
     }
 }