private void AddWmiPropertiesToWrangler(ResultWrangler Wrangler, IEnumerable <ManagementObject> WmiObjectList, List <KeyValuePair <string, XElement> > PropertyTemplates) { foreach (ManagementObject m in WmiObjectList) { Wrangler.NewResult(); FormattedProperty prop = null; //if properties have been specified in the xml, query them directly in order if (PropertyTemplates.Count != 0) { foreach (KeyValuePair <string, XElement> template in PropertyTemplates) { prop = new FormattedProperty(template.Value); prop.Input = m.GetPropertyValue(template.Key)?.ToString(); Wrangler.AddFormattedProperty(prop); } } //if properties not set, add them all else { foreach (PropertyData property in m.Properties) { prop = new FormattedProperty(); prop.Input = property.Value?.ToString(); Wrangler.AddFormattedProperty(prop); } } } }
public override ResultWrangler ProcessQuery() { //if someone hasn't supplied to queries to compare, just return null i.e. invalid result if (this._querylist.Queries.Count < 2) { return(null); } ResultWrangler wrangler = new ResultWrangler(); string first = this._querylist.Queries[0]?.GetResultWrangler()?.GetString(); for (int i = 1; i < this._querylist.Queries.Count; i++) { string second = this._querylist.Queries[i].GetResultWrangler()?.GetString(); wrangler.NewResult(); FormattedProperty prop = new FormattedProperty(); prop.Name = "Result"; if (first == second) { prop.Input = this._truevalue; } else { prop.Input = this._falsevalue; } wrangler.AddFormattedProperty(prop); } return(wrangler); }