private void ProcessManagementObject()

in Lib/Collectors/ServiceCollector.cs [226:306]


        private void ProcessManagementObject(ManagementObject service)
        {
            try
            {
                if (TryGetPropertyValue(service, "Name") is string name)
                {
                    var obj = new ServiceObject(name);

                    if (bool.TryParse(TryGetPropertyValue(service, "AcceptPause"), out bool acceptPause))
                        obj.AcceptPause = acceptPause;

                    if (bool.TryParse(TryGetPropertyValue(service, "AcceptStop"), out bool acceptStop))
                        obj.AcceptStop = acceptStop;

                    obj.Caption = TryGetPropertyValue(service, "Caption");

                    if (uint.TryParse(TryGetPropertyValue(service, "CheckPoint"), out uint checkpoint))
                        obj.CheckPoint = checkpoint;

                    obj.CreationClassName = TryGetPropertyValue(service, "CreationClassName");

                    if (bool.TryParse(TryGetPropertyValue(service, "DelayedAutoStart"), out bool delayedAutoStart))
                        obj.DelayedAutoStart = delayedAutoStart;

                    obj.Description = TryGetPropertyValue(service, "Description");

                    if (bool.TryParse(TryGetPropertyValue(service, "DesktopInteract"), out bool desktopInteract))
                        obj.DesktopInteract = desktopInteract;

                    obj.DisplayName = TryGetPropertyValue(service, "DisplayName");

                    obj.ErrorControl = TryGetPropertyValue(service, "ErrorControl");

                    if (uint.TryParse(TryGetPropertyValue(service, "ExitCode"), out uint exitCode))
                        obj.ExitCode = exitCode;

                    if (DateTime.TryParse(service.GetPropertyValue("InstallDate")?.ToString(), out DateTime dateTime))
                    {
                        obj.InstallDate = dateTime;
                    }

                    obj.PathName = TryGetPropertyValue(service, "PathName");

                    if (uint.TryParse(TryGetPropertyValue(service, "ProcessId"), out uint processId))
                        obj.ProcessId = processId;

                    if (uint.TryParse(TryGetPropertyValue(service, "ServiceSpecificExitCode"), out uint serviceSpecificExitCode))
                        obj.ServiceSpecificExitCode = serviceSpecificExitCode;

                    obj.ServiceType = TryGetPropertyValue(service, "ServiceType");

                    if (bool.TryParse(TryGetPropertyValue(service, "Started"), out bool started))
                        obj.Started = started;

                    obj.StartMode = TryGetPropertyValue(service, "StartMode");
                    obj.StartName = TryGetPropertyValue(service, "StartName");
                    obj.State = TryGetPropertyValue(service, "State");
                    obj.Status = TryGetPropertyValue(service, "Status");
                    obj.SystemCreationClassName = TryGetPropertyValue(service, "SystemCreationClassName");
                    obj.SystemName = TryGetPropertyValue(service, "SystemName");

                    if (uint.TryParse(TryGetPropertyValue(service, "TagId"), out uint tagId))
                        obj.TagId = tagId;

                    if (uint.TryParse(TryGetPropertyValue(service, "WaitHint"), out uint waitHint))
                        obj.WaitHint = waitHint;

                    HandleChange(obj);
                }
            }
            catch (Exception e) when (
                e is TypeInitializationException ||
                e is PlatformNotSupportedException)
            {
                Log.Warning(Strings.Get("CollectorNotSupportedOnPlatform"), GetType().ToString());
            }
            catch (Exception e)
            {
                Log.Warning(e, "Failed to grok Service Collector object at {0}.", service.Path);
            }
        }