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); }
/// <summary> /// Create a new ResultWrangler, using this as a template. Copy separator and IncludeNullValues /// </summary> /// <returns></returns> public ResultWrangler Clone() { ResultWrangler newwrangler = new ResultWrangler(); newwrangler.Separator = this.Separator; newwrangler.IncludeNullValues = this.IncludeNullValues; return(newwrangler); }
public override ResultWrangler ProcessQuery() { foreach (Conditional condition in this._conditions) { ResultWrangler returnval = condition.GetResultWrangler(); if ((returnval != null) && (this.ShouldIgnore(returnval.GetString()) == false)) { return(returnval); } } return(this._else?.GetResultWrangler()); }
public ResultWrangler GetResultWrangler() { foreach (IQuery query in this._queries) { ResultWrangler wrangler = query.GetResultWrangler(); if (wrangler != null) { return(wrangler); } } return(null); }
public List <FormattedProperty> GetAllPropertyFormatters() { List <FormattedProperty> formatterlist = new List <FormattedProperty>(); foreach (IQuery query in this._queries) { ResultWrangler wrangler = query.GetResultWrangler(); if (wrangler != null) { formatterlist.AddRange(wrangler.GetAllPropertyFormatters()); } } return(formatterlist); }