public object Get(SystemInfoRequest request)
 {
     lock (Image.ConvertQueue)
     {
         return(new SystemInfoResponse()
         {
             ConversionQueue = Image.ConvertQueue.Select(x => Path.GetFileName(x.Output)).ToList()
         });
     }
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        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)));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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"]));
        }