コード例 #1
0
        private void DeleteEventType(IElement eventType)
        {
            // Get the configuration for this source.

            ManagementObject config = WmiUtil.GetObject(_scope, GetPath(eventType));

            if (config != null)
            {
                DeleteEventType(config);
            }
        }
コード例 #2
0
        private void DeleteSource(Source source)
        {
            // Get the configuration for this source.

            ManagementObject config = WmiUtil.GetObject(_scope, GetPath(source));

            if (config != null)
            {
                DeleteSource(config);
            }
        }
コード例 #3
0
        private void DeleteNamespace(Namespace ns)
        {
            // Get the configuration for this source.

            ManagementObject config = WmiUtil.GetObject(_scope, GetPath(ns));

            if (config != null)
            {
                DeleteNamespace(config);
            }
        }
コード例 #4
0
        private void UpdateEventType(EventType eventType)
        {
            // Try to get an existing source.

            ManagementObject config = WmiUtil.GetObject(_scope, GetPath(eventType));

            if (config == null)
            {
                // Not found, so create a new instance.

                config = CreateInstance(Constants.Wmi.EventType.Class);
                WmiUtil.SetPropertyValue(config, Constants.Wmi.NameProperty, eventType.Name);
            }

            // Update the rest of the properties and save.

            WmiUtil.SetPropertyValue(config, Constants.Wmi.EventType.IsEnabledProperty, eventType.IsEnabled);
            config.Put();
        }
コード例 #5
0
        private void UpdateSource(Source source)
        {
            // Try to get an existing source.

            ManagementObject config = WmiUtil.GetObject(_scope, GetPath(source));

            if (config == null)
            {
                // Not found, so create a new instance.

                config = CreateInstance(Constants.Wmi.Source.Class);
                WmiUtil.SetPropertyValue(config, Constants.Wmi.ParentProperty, source.Parent == null ? string.Empty : source.Parent.FullName);
                WmiUtil.SetPropertyValue(config, Constants.Wmi.NameProperty, source.Name);
            }

            // Update the rest of the properties and save.

            string enabledEvents = JoinString(source.EnabledEvents, Constants.Module.ListSeparator);

            WmiUtil.SetPropertyValue(config, Constants.Wmi.Source.EnabledEventsProperty, enabledEvents);
            config.Put();
        }