Example #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(ExceptionTitle.MatchResultFailed.ToString(), "match result failed", 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);
            }
        }
Example #2
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(ExceptionTitle.MatchResultFailed.ToString(), "match result failed", 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;
     }
 }