本文整理汇总了C#中System.Management.ManagementClass.IsAssociation方法的典型用法代码示例。如果您正苦于以下问题:C# ManagementClass.IsAssociation方法的具体用法?C# ManagementClass.IsAssociation怎么用?C# ManagementClass.IsAssociation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.ManagementClass
的用法示例。
在下文中一共展示了ManagementClass.IsAssociation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitQueryResultGrid
/// <summary>
/// Initializes the query results grid to receive results for the specified ManagementClass.
/// </summary>
/// <param name="c">The System.Management.ManagementClass to be displayed.</param>
private void InitQueryResultGrid(ManagementClass c, String query)
{
// Get the type of query to build columns for
var queryType = query.GetWqlQueryType();
// Reset grid config
this.gridQueryResults.Rows.Clear();
this.gridQueryResults.Columns.Clear();
// Configure grid context menu
this.btnGetAssociatorsOf.Visible =
this.btnGetReferencesOf.Visible =
this.btnResultPropertiesSeparater.Visible =
queryType == WqlQueryType.Select;
// Create column for result count
DataGridViewTextBoxColumn colIndex = new DataGridViewTextBoxColumn();
colIndex.Name = colIndex.HeaderText = "#";
colIndex.DefaultCellStyle.BackColor = SystemColors.ControlLight;
colIndex.DefaultCellStyle.ForeColor = SystemColors.ControlDark;
colIndex.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
// Create column for result inspector link
DataGridViewImageColumn colInspector = new DataGridViewImageColumn();
colInspector.Image = this.ImageList1.Images["Property"];
colInspector.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
this.gridQueryResults.Columns.AddRange(colIndex, colInspector);
// Add a column for each available result property
if (queryType == WqlQueryType.Select)
{
// Extract properties from selected fields in the query itself.
// This may be all properties or a subset (Eg. SELECT Caption from Win32_ComputerSystem).
var properties = query.GetWqlQueryProperties(c);
// Create a column for each property
foreach (PropertyData p in properties)
{
DataGridViewColumn colProperty;
// Create hyperlink columns for objects
if (p.Type == CimType.Object || p.Type == CimType.Reference)
{
colProperty = new DataGridViewLinkColumn();
DataGridViewLinkColumn link = (DataGridViewLinkColumn)colProperty;
link.LinkBehavior = LinkBehavior.HoverUnderline;
link.VisitedLinkColor = link.LinkColor;
link.ActiveLinkColor = link.LinkColor;
}
else
{
colProperty = new DataGridViewTextBoxColumn();
}
colProperty.Name = colProperty.HeaderText = p.Name;
if (p.IsKey())
{
colProperty.DefaultCellStyle.BackColor = SystemColors.Info;
colProperty.DefaultCellStyle.ForeColor = SystemColors.InfoText;
}
if (c.IsAssociation())
colProperty.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
else
colProperty.AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
this.gridQueryResults.Columns.Add(colProperty);
}
}
else
{
// Create columns for a ASSOCIATORS OF or REFERENCES OF query
DataGridViewLinkColumn col = new DataGridViewLinkColumn();
col.LinkBehavior = LinkBehavior.HoverUnderline;
col.VisitedLinkColor = col.LinkColor;
col.ActiveLinkColor = col.LinkColor;
col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
switch (queryType)
{
case WqlQueryType.AssociatorsOf:
col.Name = "Association";
break;
case WqlQueryType.ReferencesOf:
col.Name = "Reference";
break;
}
this.gridQueryResults.Columns.Add(col);
}
}