Exemplo n.º 1
0
        /// <summary>
        /// Executes a query to retrieve objects.
        /// </summary>
        /// <param name="connection">the extended <see cref="WmiConnection"/> object.</param>
        /// <param name="query">The query which will be executed.</param>
        /// <returns>An object collection that contains the result set of the query.</returns>
        /// <exception cref="System.ObjectDisposedException">Object already disposed.</exception>
        /// <exception cref="System.ArgumentNullException"><paramref name="query"/> is null.</exception>
        #endregion
        public static WmiObjectEnumerator ExecuteQuery(this WmiConnection connection, string query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(MethodBase.GetCurrentMethod().GetParameters()[1].Name);
            }

            return(connection.ExecuteQuery(connection.CreateQuery(query)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a <see cref="WmiQuery"/> for the given <see cref="string"/>.
        /// </summary>
        /// <param name="connection">the extended <see cref="WmiConnection"/> object.</param>
        /// <param name="wql">The query.</param>
        /// <returns>The created <see cref="WmiQuery"/>.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="wql"/> is null.</exception>
        #endregion
        public static WmiQuery CreateQuery(this WmiConnection connection, string wql)
        {
            if (wql == null)
            {
                throw new ArgumentNullException(MethodBase.GetCurrentMethod().GetParameters()[1].Name);
            }

            return(new WmiQuery(connection, wql));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WmiQuery"/> class.
        /// </summary>
        /// <param name="connection">The wmi connection who should be used.</param>
        /// <param name="wql">
        /// The string representation of a WMI Query Language (WQL) .
        /// <para />
        /// Example: SELECT * FROM Win32_LogicalDisk WHERE FreeSpace &lt; 2097152
        /// </param>
        /// <param name="enumeratorBehaviorOptions">The options that can be used to adjust the behavior of the created enumerator.</param>
        /// <exception cref="ArgumentNullException"><paramref name="connection"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="wql"/> is null.</exception>
        #endregion
        public WmiQuery(WmiConnection connection, string wql, EnumeratorBehaviorOption enumeratorBehaviorOptions)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(MethodBase.GetCurrentMethod().GetParameters()[0].Name);
            }

            if (wql == null)
            {
                throw new ArgumentNullException(MethodBase.GetCurrentMethod().GetParameters()[1].Name);
            }

            this.wql = wql;

            this.connection = connection;

            this.enumeratorBehaviorOptions = enumeratorBehaviorOptions;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WmiQuery"/> class.
 /// </summary>
 /// <param name="connection">The wmi connection who should be used.</param>
 /// <param name="wql">
 /// The string representation of a WMI Query Language (WQL) .
 /// <para />
 /// Example: SELECT * FROM Win32_LogicalDisk WHERE FreeSpace &lt; 2097152
 /// </param>
 /// <exception cref="ArgumentNullException"><paramref name="connection"/> is null.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="wql"/> is null.</exception>
 #endregion
 public WmiQuery(WmiConnection connection, string wql)
     : this(connection, wql, EnumeratorBehaviorOption.ReturnImmediately)
 {
 }