public Source CloneProperties(ISourceParent parent, string name) { Source source = parent.Catalogue.CreateSource(parent, name); source.CopyMembers(this, false); return(source); }
public Source GetSource(ISourceParent parent, string name, bool ignoreCase) { string query = "SELECT * FROM " + Constants.Wmi.Source.Class + " WHERE Parent = '" + parent.FullName + "' AND Name = '" + name + "'"; var searcher = new ManagementObjectSearcher(_scope, new ObjectQuery(query)); using (ManagementObjectCollection configs = searcher.Get()) { Debug.Assert(configs.Count <= 1, "configs.Count <= 1"); IEnumerator enumerator = configs.GetEnumerator(); if (!enumerator.MoveNext()) { return(null); // Source not found. } Source source = CreateSource(parent, (ManagementObject)enumerator.Current); // WQL is case-isensitive, so check the case below, if needed. if (!ignoreCase && source.Name != name) { return(null); } parent.AddIfNotLoaded(source); return(source); } }
public Source Clone(ISourceParent parent, string name) { Source source = parent.Catalogue.CreateSource(parent, name); source.CopyMembers(this, false); CopyChildCollections(this); return(source); }
private static Source CreateSource(ISourceParent parent, ManagementBaseObject config) { // Get the properties. var name = (string)WmiUtil.GetPropertyValue(config, Constants.Wmi.NameProperty); var enabledEvents = (string)WmiUtil.GetPropertyValue(config, Constants.Wmi.Source.EnabledEventsProperty); string[] enabledEventsArray = SplitString(enabledEvents, Constants.Module.ListSeparator); return(parent.Catalogue.CreateSource(parent, name, enabledEventsArray)); }
public override Source[] GetSources(ISourceParent parent) { // Search. var sources = new ArrayList(); var searcher = new ManagementObjectSearcher(_scope, GetChildQuery(Constants.Wmi.Source.Class, parent.FullName)); using (ManagementObjectCollection configs = searcher.Get()) { foreach (ManagementObject config in configs) { sources.Add(CreateSource(parent, config)); } } return((Source[])sources.ToArray(typeof(Source))); }
private static void CopyElement(ISourceParent parent, Source source) { // Check whether the source already exists. Source thisSource = parent.Sources[source.RelativeQualifiedReference]; if (thisSource == null) { // Doesn't exist so create new clone. thisSource = source.CloneProperties(parent, source.Name); parent.Sources.Add(thisSource); } else { // Already exists so copy details. thisSource.CopyProperties(source); } }
// Sources public virtual Source[] GetSources(ISourceParent parent) { return(new Source[0]); }
private static void AddEventStatesForSources(ISourceParent parent, IEnumerable <string> eventsToCheck, IList enabled, IList disabled, IList mixed, bool setFromFirstSource) { IEnumerator enumerator = parent.Sources.GetEnumerator(); if (setFromFirstSource) { // When processing the first source just set our states from its states. if (enumerator.MoveNext()) { var source = (Source)enumerator.Current; ReadOnlyStringList childEnabled = source.EnabledEvents; foreach (string eventName in eventsToCheck) { if (childEnabled.Contains(eventName)) { enabled.Add(eventName); } else { disabled.Add(eventName); } } } } while (enumerator.MoveNext()) { // For subsequent children look for states that change our state for an event from enabled or // disabled to mixed. Once an event is in "mixed" state that won't change. var source = (Source)enumerator.Current; ReadOnlyStringList childEnabled = source.EnabledEvents; int index = 0; while (index < enabled.Count) { var eventName = (string)enabled[index]; if (!childEnabled.Contains(eventName)) { // This event was enabled for all children so far, but not for this one - now it's mixed. enabled.RemoveAt(index); mixed.Add(eventName); } else { index++; } } index = 0; while (index < disabled.Count) { var eventName = (string)disabled[index]; if (childEnabled.Contains(eventName)) { // This event was disabled for all children so far, but not for this one - now it's mixed. disabled.RemoveAt(index); mixed.Add(eventName); } else { index++; } } } }
public static void Copy(Catalogue toCatalogue, Source source, ReadOnlyOption readOnlyOption, bool isReferenced) { ISourceParent parent = toCatalogue.EnsureSourceParent(source.Parent.FullName); CopyElement(parent, source); }
public Source CreateSource(ISourceParent parent, string name) { return(new Source(parent, _interner.Intern(name))); }
// Source public Source CreateSource(ISourceParent parent, string name, string[] enabledEvents) { return(new Source(parent, _interner.Intern(name), enabledEvents, _interner)); }
public NewSourceWizard(ISourceParent parent) { m_parent = parent; m_source = null; }