The correct way to resolve this issue and as many Mono-related issues, and how to deal with differences in behavior across different operating systems (for example, the Ping class is a real pain), you should probably use the ProcessStartInfo class and do the parsing.
IMHO, this is a real solution that requires a lot of work (remember that sometimes console commands are localized = /) to make it truly "platform independent". Ironically, you will have to make a great platform to work to achieve your goals, but in any case, it can be a way to achieve your goal.
public static class SystemInformation { static SystemInformation() { switch (Environment.OSVersion.Platform) { case PlatformID.Unix: case PlatformID.MacOSX: break; // Let "assume" for a while that our default case // below covers all Windows related Operating Systems... default: break; } } private readonly static CPUInformation _cpu; public static CPUInformation CPU { get { return SystemInformation._cpu; } } private readonly static OSInformation _os; public static OSInformation OS { get { return SystemInformation._os; } } private readonly static RAMInformation _ram; public static RAMInformation RAM { get { return SystemInformation._ram; } } private readonly static GPUInformation _gpu; public static GPUInformation GPU { get { return SystemInformation._gpu; } } } public sealed class CPUInformation { internal CPUInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... } public sealed class OSInformation { internal OSInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... } public sealed class GPUInformation { internal GPUInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... } public sealed class RAMInformation { internal RAMInformation( /*... Add some parameters here .. */ ) { // Fill the constructor... } // Add some properties here... }
source share