Example #1
0
        public static ctrl_TableList show_in_TableList(this List <ManagementBaseObject> searchResults, ctrl_TableList tableList)
        {
            if (searchResults.isNull() || tableList.isNull())
            {
                return(tableList);
            }
            var wmiQueryItems = searchResults.createObjectWithSearchResults();

            if (wmiQueryItems.isNull() || wmiQueryItems.size() == 0)
            {
                tableList.title("No items in WMI search results");
                return(tableList);
            }
            tableList.visible(false);

            var properties = wmiQueryItems[0].type().properties();

            foreach (var property in  properties)
            {
                tableList.add_Column(property.Name);
            }

            foreach (var wmiQueryItem in  wmiQueryItems)
            {
                tableList.add_Row(wmiQueryItem.getProperties_AsArray().Select <object, string>(o => o.str()).toList());
            }

            tableList.title("Showing {0} values form {1} search results".format(properties.size(), searchResults.size()));
            tableList.visible(true);
            return(tableList);
        }