Exemplo n.º 1
0
        /// <summary>
        /// Retrieve system information, using the given SysInfoQuery to determine what information to retrieve
        /// </summary>
        /// <param name="sysInfoQuery">the query to determine what information to retrieve</param>
        /// <returns>a SysInfoResult ie containing the results of the query</returns>
        public SysInfoResult Retrieve(SysInfoQuery sysInfoQuery)
        {
            _sysInfoQuery = sysInfoQuery;
            _sysInfoSearcher = new ManagementObjectSearcher(string.Format("SELECT * FROM {0}", _sysInfoQuery.QueryText));
            _sysInfoResult = new SysInfoResult(_sysInfoQuery.Name);

            foreach (ManagementObject managementObject in _sysInfoSearcher.Get())
            {
                _sysInfoResult.AddNode(managementObject.GetPropertyValue(_sysInfoQuery.DisplayField).ToString().Trim());
                _sysInfoResult.AddChildren(GetChildren(managementObject));
            }
            return _sysInfoResult;
        }
        /// <summary>
        /// Retrieve system information, using the given SysInfoQuery to determine what information to retrieve
        /// </summary>
        /// <param name="sysInfoQuery">the query to determine what information to retrieve</param>
        /// <returns>a SysInfoResult ie containing the results of the query</returns>
        public SysInfoResult Retrieve(SysInfoQuery sysInfoQuery)
        {
            _sysInfoQuery    = sysInfoQuery;
            _sysInfoSearcher = new ManagementObjectSearcher(string.Format("SELECT * FROM {0}", _sysInfoQuery.QueryText));
            _sysInfoResult   = new SysInfoResult(_sysInfoQuery.Name);

            foreach (ManagementObject managementObject in _sysInfoSearcher.Get())
            {
                _sysInfoResult.AddNode(managementObject.GetPropertyValue(_sysInfoQuery.DisplayField).ToString().Trim());
                _sysInfoResult.AddChildren(GetChildren(managementObject));
            }
            return(_sysInfoResult);
        }