本文整理汇总了C#中String.GetWqlQueryType方法的典型用法代码示例。如果您正苦于以下问题:C# String.GetWqlQueryType方法的具体用法?C# String.GetWqlQueryType怎么用?C# String.GetWqlQueryType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String.GetWqlQueryType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ManagementQueryBroker
/// <summary>
/// Creates a new instance of System.Management.ManagementQueryBroker.
/// </summary>
/// <param name="query">The WQL Query to be executed.</param>
/// <param name="namespacePath">Namespace path of the ManagementPath within which to execute a query.</param>
/// <param name="connectionOptions">Specifies all settings required to make a WMI connection.</param>
public ManagementQueryBroker(String query, ManagementScope scope)
{
this.Query = query;
this.scope = scope;
this.QueryType = query.GetWqlQueryType();
this.Results = new List<ManagementBaseObject>();
this.queryObserver = new ManagementOperationObserver();
this.queryObserver.ObjectReady += new ObjectReadyEventHandler(queryObserver_ObjectReady);
this.queryObserver.Completed += new CompletedEventHandler(queryObserver_Completed);
// Extract class name from query
MatchCollection matches = Regex.Matches(query, @"(select.*from\s+|references\s+of\s+{|associators\s+of\s+{)([A-Za-z0-9_]+)", RegexOptions.IgnoreCase);
if (matches.Count != 1 || !matches[0].Groups[2].Success)
throw new ArgumentException("Could not determine class name from query.");
// Get class descriptor to assist with queries
var options = new ObjectGetOptions();
options.UseAmendedQualifiers = true;
var className = matches[0].Groups[2];
var classPath = new ManagementPath(String.Format("\\\\{0}\\{1}:{2}", scope.Path.Server, scope.Path.NamespacePath, className));
this.ResultClass = new ManagementClass(this.scope, classPath, options);
// Configure event queries
this.IsEventQuery = this.ResultClass.IsEvent();
if (this.IsEventQuery && query.ToLowerInvariant().Contains("group within"))
{
// Change result class to '__AggregateEvent' if this is an event query with a grouping
classPath = new ManagementPath(String.Format("\\\\{0}\\{1}:__AggregateEvent", scope.Path.Server, scope.Path.NamespacePath));
this.ResultClass = new ManagementClass(this.scope, classPath, new ObjectGetOptions());
}
// Get value maps for the query
this.ResultClassValueMaps = this.ResultClass.GetValueMaps();
}
示例2: IsWqlReferencesOfQuery
public static Boolean IsWqlReferencesOfQuery(String query)
{
return query.GetWqlQueryType() == WqlQueryType.ReferencesOf;
}
示例3: IsWqlSelectQuery
public static Boolean IsWqlSelectQuery(String query)
{
return query.GetWqlQueryType() == WqlQueryType.Select;
}
示例4: IsWqlAssociatorsOfQuery
public static Boolean IsWqlAssociatorsOfQuery(String query)
{
return query.GetWqlQueryType() == WqlQueryType.AssociatorsOf;
}