Esempio n. 1
0
            public static UInt64 GetProperty(MemPropOSX prop, string output)
            {
                var propName = Regex.Escape(prop.GetAttributeProperty <SysctlPropertyNameAttribute, string>(attribute => attribute.Name));
                var match    = new Regex(propName + @"\s*?[=:]\s*?(?<" + propName + @">\d+)", RegexOptions.Multiline).Match(output);

                return(match.Success ? match.Groups[propName].Value.ParseUInt64Invariant() : 0);
            }
Esempio n. 2
0
 private static ulong GetMemoryOSX(MemPropOSX prop)
 {
     using (var process = new Process())
     {
         process.StartInfo = new ProcessStartInfo("sysctl", "-a")
         {
             UseShellExecute        = false,
             RedirectStandardOutput = true,
             RedirectStandardError  = true,
             CreateNoWindow         = true,
             WindowStyle            = ProcessWindowStyle.Hidden,
         };
         process.Start();
         var propName = prop.GetAttributeProperty <DescriptionAttribute, string>(attribute => attribute.Description);
         var output   = process.StandardOutput.ReadToEnd();
         var match    = new Regex(@"hw\." + propName + @"\s+?=\s+?(?<" + propName + @">\d+)", RegexOptions.Multiline).Match(output);
         return(match.Success ? UInt64.Parse(match.Groups[propName].Value) : 0);
     }
 }
Esempio n. 3
0
 private static ulong GetMemoryOSX(MemPropOSX prop)
 {
     using (var process = new Process())
     {
         process.StartInfo = new ProcessStartInfo("sysctl", "-a")
                             {
                                 UseShellExecute = false,
                                 RedirectStandardOutput = true,
                                 RedirectStandardError = true,
                                 CreateNoWindow = true,
                                 WindowStyle = ProcessWindowStyle.Hidden,
                             };
         process.Start();
         var propName = prop.GetAttributeProperty<DescriptionAttribute, string>(attribute => attribute.Description);
         var output = process.StandardOutput.ReadToEnd();
         var match = new Regex(@"hw\." + propName + @"\s+?=\s+?(?<" + propName + @">\d+)", RegexOptions.Multiline).Match(output);
         return match.Success ? UInt64.Parse(match.Groups[propName].Value) : 0;
     }
 }