public object Get(SystemInfoRequest request) { lock (Image.ConvertQueue) { return(new SystemInfoResponse() { ConversionQueue = Image.ConvertQueue.Select(x => Path.GetFileName(x.Output)).ToList() }); } }
public static IEnumerable <PhysicalAddress> GetMacAddressWMI() { Func <ManagementObject, PhysicalAddress> converter = mo => PhysicalAddress.Parse(Convert.ToString(mo["MacAddress"])); SystemInfoRequest <PhysicalAddress> request = new SystemInfoRequest <PhysicalAddress>(SystemInfoType.Win32_NetworkAdapterConfiguration, converter) { Filter = mo => Convert.ToBoolean(mo["IPEnabled"]) }; return(SystemInfo.Get(request)); }
public static bool IsRunning(this Process thisValue) { if (!IsAwaitable(thisValue)) { return(false); } SystemInfoRequest request = new SystemInfoRequest(SystemInfoType.Win32_Process) { SelectExpression = "ProcessId", Filter = mo => Convert.ToInt32(mo["ProcessId"]) == thisValue.Id }; return(SystemInfo.Get(request).Any()); }
public static Process GetChild([NotNull] this Process thisValue, [NotNull] Predicate <Process> predicate) { if (!IsAwaitable(thisValue)) { return(null); } Func <ManagementObject, Process> converter = mo => ProcessHelper.TryGetProcessById(Convert.ToInt32(mo["ProcessID"]), out Process p) ? p : null; SystemInfoRequest <Process> request = new SystemInfoRequest <Process>(SystemInfoType.Win32_Process, converter) { WhereExpression = $"ParentProcessID={thisValue.Id}" }; return(SystemInfo.Get(request).FirstOrDefault(p => p != null && predicate(p))); }
public static IEnumerable <Process> GetChildren(this Process thisValue) { if (!IsAwaitable(thisValue)) { return(Enumerable.Empty <Process>()); } Func <ManagementObject, Process> converter = mo => ProcessHelper.TryGetProcessById(Convert.ToInt32(mo["ProcessID"]), out Process p) ? p : null; SystemInfoRequest <Process> request = new SystemInfoRequest <Process>(SystemInfoType.Win32_Process, converter) { WhereExpression = $"ParentProcessID={thisValue.Id}" }; return(SystemInfo.Get(request).Where(p => p != null)); }
public static (string ExecutablePath, string CommandLine) GetCommandLine(this Process thisValue) { if (!IsAwaitable(thisValue)) { return(null, null); } SystemInfoRequest request = new SystemInfoRequest(SystemInfoType.Win32_Process) { SelectExpression = "ProcessId, ExecutablePath, CommandLine", Filter = e => Convert.ToInt32(e["ProcessId"]) == thisValue.Id }; ManagementObject mo = SystemInfo.FirstOrDefault(request); return(mo == null ? (null, null) : ((string)mo["ExecutablePath"], (string)mo["CommandLine"])); }