コード例 #1
0
ファイル: WmiQuery.cs プロジェクト: SomeZyla/TsGui
        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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: GuiVariableQuery.cs プロジェクト: SomeZyla/TsGui
        private new void LoadXml(XElement InputXml)
        {
            base.LoadXml(InputXml);

            XElement   x;
            XAttribute xattrib;

            this._processingwrangler.NewResult();

            x = InputXml.Element("Variable");
            if (x != null)
            {
                //check for new xml syntax. If the name attribute doesn't exist, setup for the
                //legacy layout.
                xattrib = x.Attribute("Name");
                if (xattrib == null)
                {
                    this._formatter      = new FormattedProperty();
                    this._formatter.Name = x.Value;
                }
                else
                {
                    this._formatter = new FormattedProperty(x);
                }

                this._processingwrangler.AddFormattedProperty(this._formatter);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: ResultWrangler.cs プロジェクト: SomeZyla/TsGui
        /// <summary>
        /// Add a PropertyFormatter to the ResultWrangler's current list
        /// </summary>
        /// <param name="Formatter"></param>
        public void AddFormattedProperty(FormattedProperty Formatter)
        {
            Result result;

            this._results.TryGetValue(this._currentresultlist, out result);
            if (result != null)
            {
                result.Add(Formatter);
            }
        }
コード例 #5
0
ファイル: Result.cs プロジェクト: SomeZyla/TsGui
 public void Add(FormattedProperty newproperty)
 {
     if (this.KeyProperty == null)
     {
         this.KeyProperty = newproperty;
     }
     else
     {
         this.Properties.Add(newproperty);
     }
 }
コード例 #6
0
ファイル: OptionValueQuery.cs プロジェクト: SomeZyla/TsGui
        private new void LoadXml(XElement InputXml)
        {
            base.LoadXml(InputXml);

            XElement x;

            this._processingwrangler.NewResult();

            x = InputXml.Element("ID");
            if (x != null)
            {
                this._formatter = new FormattedProperty(x);
                this._processingwrangler.AddFormattedProperty(this._formatter);
            }
        }