Skip to content

Commit 72b86d7

Browse files
committed
Added documentation for System.Management.Linq.ManagementObjects
1 parent 39f08f0 commit 72b86d7

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

Linq/ManagementObjects.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,58 @@
22
using Types;
33
using Types.Base;
44

5+
/// <summary>
6+
/// Provides entry points for querying WMI (Windows Management Instrumentation) objects using strongly-typed LINQ queries.
7+
/// </summary>
8+
/// <remarks>
9+
/// <para>
10+
/// The <see cref="ManagementObjects"/> class enables LINQ-to-WQL queries over WMI classes, returning either strongly-typed objects or generic WMI objects.
11+
/// </para>
12+
/// <para>
13+
/// Use <see cref="Get{T}"/> for strongly-typed queries (e.g., <c>ManagementObjects.Get&lt;Process&gt;()</c>), or <see cref="Get(string)"/> for dynamic access by class name.
14+
/// </para>
15+
/// <para>
16+
/// Example usage:
17+
/// <code>
18+
/// using System.Management.Linq;
19+
/// using System.Management.Types.Win32;
20+
///
21+
/// var processes = ManagementObjects.Get&lt;Process&gt;()
22+
/// .Where(p => p.Name == "explorer.exe")
23+
/// .ToList();
24+
/// </code>
25+
/// </para>
26+
/// </remarks>
527
public static class ManagementObjects
628
{
29+
/// <summary>
30+
/// Returns a queryable sequence of strongly-typed WMI objects for the specified type <typeparamref name="T"/>.
31+
/// </summary>
32+
/// <typeparam name="T">
33+
/// The target type representing a WMI class (e.g., <c>System.Management.Types.Win32.Process</c>).
34+
/// </typeparam>
35+
/// <returns>
36+
/// An <see cref="IQueryable{T}"/> for LINQ queries against the WMI class associated with <typeparamref name="T"/>.
37+
/// </returns>
38+
/// <exception cref="NotSupportedException">
39+
/// Thrown if <typeparamref name="T"/> is not mapped to a WMI class.
40+
/// </exception>
41+
/// <remarks>
42+
/// The mapping between <typeparamref name="T"/> and the WMI class name is resolved via <see cref="InstanceFactory.GetClassNameOf{T}"/>.
43+
/// </remarks>
744
public static IQueryable<T> Get<T>()
845
=> new ManagementObjectQueryable<T>(InstanceFactory.GetClassNameOf<T>() ?? throw new NotSupportedException($"Type {typeof(T).Name} is not supported by the {typeof(ManagementObjectQueryable<>)}."));
946

47+
/// <summary>
48+
/// Returns a queryable sequence of generic WMI objects for the specified WMI class name.
49+
/// </summary>
50+
/// <param name="className">The WMI class name (e.g., <c>"Win32_Process"</c>).</param>
51+
/// <returns>
52+
/// An <see cref="IQueryable{_Object}"/> for LINQ queries against the specified WMI class.
53+
/// </returns>
54+
/// <remarks>
55+
/// Use this overload for dynamic or late-bound scenarios where a strongly-typed class is not available.
56+
/// </remarks>
1057
public static IQueryable<_Object> Get(string className)
1158
=> new ManagementObjectQueryable<_Object>(className);
1259
}

0 commit comments

Comments
 (0)