本文整理汇总了C#中System.Management.ManagementObjectCollection类的典型用法代码示例。如果您正苦于以下问题:C# ManagementObjectCollection类的具体用法?C# ManagementObjectCollection怎么用?C# ManagementObjectCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ManagementObjectCollection类属于System.Management命名空间,在下文中一共展示了ManagementObjectCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Baseboard
public Baseboard(ManagementObjectCollection queryResult)
{
foreach (var obj in queryResult) {
foreach (var data in obj.Properties) {
switch (data.Name) {
case "Manufacturer":
this.Manufacturer = data.Value.ToString();
break;
case "Model":
try {
this.Model = data.Value.ToString();
} catch (NullReferenceException) {
this.Model = String.Empty;
}
break;
case "Product":
this.Product = data.Value.ToString();
break;
case "SerialNumber":
this.SerialNumber = data.Value.ToString();
break;
}
}
}
}
开发者ID:JamesWClark,项目名称:Scour,代码行数:25,代码来源:Baseboard.cs
示例2: VideoController
public VideoController(ManagementObjectCollection queryResult)
{
foreach (var obj in queryResult) {
foreach (var data in obj.Properties) {
switch (data.Name) {
case "AdapterCompatibility":
this.AdapterCompatibility = data.Value.ToString();
break;
case "AdapterRam":
this.AdapterRam = data.Value.ToString();
break;
case "Name":
this.Name = data.Value.ToString();
break;
case "VideoModeDescription":
this.VideoModeDescription = data.Value.ToString();
break;
case "VideoProcessor":
try {
this.VideoProcessor = data.Value.ToString();
} catch (NullReferenceException) {
this.VideoProcessor = String.Empty;
}
break;
case "VideoMemoryType":
this.VideoMemoryType = data.Value.ToString();
break;
}
}
}
}
开发者ID:JamesWClark,项目名称:Scour,代码行数:31,代码来源:VideoController.cs
示例3: CCM_DCMBaselines
/// <summary>
/// Get DCM Baselines (Class SMS_DesiredConfiguration)
/// </summary>
/// <param name="refresh">true=reload;false=get cached objects</param>
/// <returns>Class SMS_DesiredConfiguration</returns>
public ManagementObjectCollection CCM_DCMBaselines(bool refresh)
{
if (refresh)
{
oDCMBaselines = null;
}
return CCM_DCMBaselines();
}
开发者ID:przemo098,项目名称:ccmmanager,代码行数:13,代码来源:DesiredConfigurationManagement.cs
示例4: PopulateClassesList
public WmiResult PopulateClassesList(ManagementObjectCollection pManagementClasses)
{
Classes = new List<string>();
CollectedClasses = pManagementClasses;
foreach (ManagementObject WmiClass in pManagementClasses)
{
Classes.Add(WmiClass["__Class"].ToString());
}
return this;
}
开发者ID:Sparse,项目名称:MultiRDP,代码行数:11,代码来源:WmiResult.cs
示例5: MotherboardDevice
public MotherboardDevice(ManagementObjectCollection queryResult)
{
foreach (var obj in queryResult) {
foreach (var data in obj.Properties) {
switch (data.Name) {
case "Manufacturer":
this.Manufacturer = data.Value.ToString();
break;
}
}
}
}
开发者ID:JamesWClark,项目名称:Scour,代码行数:12,代码来源:MotherboardDevice.cs
示例6: GetFirstObjectFromCollection
/// <summary>
/// Gets the first object in a collection of ManagementObject instances.
/// </summary>
/// <param name="collection">The collection of ManagementObject instances.</param>
/// <returns>The first object in the collection</returns>
public static ManagementObject GetFirstObjectFromCollection(ManagementObjectCollection collection)
{
if (collection.Count == 0)
{
throw new ArgumentException("The collection contains no objects", "collection");
}
foreach (ManagementObject managementObject in collection)
{
return managementObject;
}
return null;
}
开发者ID:tdukaric,项目名称:Hyper-V-API,代码行数:19,代码来源:WMIUtils.cs
示例7: GetEventRecordList
public List<LogFilterRow> GetEventRecordList(ManagementObjectCollection mossos, List<string> searchTermList)
{
var eventRecordList = new List<LogFilterRow>();
int sTCount = searchTermList.Count;
foreach (var serv in ListOfServersToQuery)
{
var insertionStrings = String.Empty;
foreach (var mo in mossos)
{
var eventRec = new LogFilterRow();
string timeWrittenStr = (mo["TimeWritten"] != null) ? mo["TimeWritten"].ToString() : String.Empty;
eventRec.Time = ManagementDateTimeConverter.ToDateTime(timeWrittenStr);
// DateTime.ParseExact(timeWrittenStr, "yyyyMMddHHmmss.ffffff-zzz", provider);
eventRec.LogType = Global_Const.EVENTLOGTYPE;
eventRec.Src = serv + "\\EventLog\\" + Global_Const.SOURCE;
string sourceName = (mo["SourceName"] != null) ? mo["SourceName"].ToString() : String.Empty;
string message = (mo["Message"] != null) ? mo["Message"].ToString() : String.Empty;
if (mo["InsertionStrings"] != null)
{
var strList = (String[]) mo["InsertionStrings"];
insertionStrings = strList.Aggregate(insertionStrings,
(current, insString) => current + (" " + insString));
}
else
{
insertionStrings = String.Empty;
}
// var eventRec = new EventRecord((ManagementObject)mo);
//Filter out all data that contains records that we are interested in.
for (int index = 0; index < sTCount; index++)
{
var searchTerm = searchTermList[index];
if (sourceName.Contains(searchTerm) || message.Contains(searchTerm) ||
insertionStrings.Contains(searchTerm))
{
// eventRec.SearchT = "Word_" + index.ToString(CultureInfo.InvariantCulture);
eventRec.Msg = message + " -- " + insertionStrings;
eventRecordList.Add(eventRec);
insertionStrings = String.Empty;
message = String.Empty;
break;
}
insertionStrings = String.Empty;
message = String.Empty;
}
}
}
return eventRecordList;
}
开发者ID:patriklindstrom,项目名称:LBQ,代码行数:49,代码来源:EventLogFilterRepo.cs
示例8: DiskDrive
public DiskDrive(ManagementObjectCollection queryResult)
{
foreach (var obj in queryResult) {
foreach (var data in obj.Properties) {
switch (data.Name) {
case "Model":
this.Model = data.Value.ToString();
break;
case "Size":
this.Size = data.Value.ToString();
break;
case "Manufacturer":
this.Manufacturer = data.Value.ToString();
break;
}
}
}
}
开发者ID:JamesWClark,项目名称:Scour,代码行数:18,代码来源:DiskDrive.cs
示例9: BIOS
public BIOS(ManagementObjectCollection queryResult)
{
foreach (var obj in queryResult) {
foreach (var data in obj.Properties) {
switch (data.Name) {
case "Manufacturer":
this.Manufacturer = data.Value.ToString();
break;
case "SerialNumber":
this.SerialNumber = data.Value.ToString();
break;
case "SMBIOSBIOSVersion":
this.SMBIOSBIOSVersion = data.Value.ToString();
break;
}
}
}
}
开发者ID:JamesWClark,项目名称:Scour,代码行数:18,代码来源:BIOS.cs
示例10: Processor
public Processor(ManagementObjectCollection queryResult)
{
foreach (var obj in queryResult) {
foreach (var data in obj.Properties) {
switch (data.Name) {
case "Manufacturer":
this.Manufacturer = data.Value.ToString();
break;
case "Name":
this.Name = data.Value.ToString();
break;
case "Description":
this.Description = data.Value.ToString();
break;
case "MaxClockSpeed":
this.MaxClockSpeed = data.Value.ToString();
break;
case "L2CacheSize":
this.L2CacheSize = data.Value.ToString();
break;
case "AddressWidth":
this.AddressWidth = data.Value.ToString();
break;
case "DataWidth":
this.DataWidth = data.Value.ToString();
break;
case "NumberOfCores":
this.NumberOfCores = data.Value.ToString();
break;
case "NumberOfLogicalProcessors":
this.NumberOfLogicalProcessors = data.Value.ToString();
break;
case "ProcessorId":
this.ProcessorId = data.Value.ToString();
break;
}
}
}
}
开发者ID:JamesWClark,项目名称:Scour,代码行数:39,代码来源:Processor.cs
示例11: PhysicalMemory
public PhysicalMemory(ManagementObjectCollection queryResult)
{
foreach (var obj in queryResult) {
foreach (var data in obj.Properties) {
switch (data.Name) {
case "Capacity":
this.Capacity = data.Value.ToString();
break;
case "DataWidth":
this.DataWidth = data.Value.ToString();
break;
case "FormFactory":
this.FormFactory = data.Value.ToString();
break;
case "MemoryType":
this.MemoryType = data.Value.ToString();
break;
case "Speed":
this.Speed = data.Value.ToString();
break;
}
}
}
}
开发者ID:JamesWClark,项目名称:Scour,代码行数:24,代码来源:PhysicalMemory.cs
示例12: MessageInstanceEnumerator
public MessageInstanceEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum)
{
privObjEnum = objEnum;
}
开发者ID:navkar,项目名称:BizTalkControlCenter,代码行数:4,代码来源:MSBTS_MessageInstance.cs
示例13: MessageInstanceCollection
public MessageInstanceCollection(ManagementObjectCollection objCollection)
{
privColObj = objCollection;
}
开发者ID:navkar,项目名称:BizTalkControlCenter,代码行数:4,代码来源:MSBTS_MessageInstance.cs
示例14: ReportVMMetrics
private void ReportVMMetrics(ManagementObjectCollection vms)
{
// Create Management Service
ManagementObject vsms = hyperv.GetVSMS(this.name);
// Create Host metrics
UInt16 numberOfProcs = 0;
UInt16 processorLoad = 0;
UInt64 memoryUsage = 0;
UInt64 hostCapacityBytes = hyperv.GetHostMemoryCapacityBytes(this.name);
foreach (ManagementObject vm in vms)
{
// Name of VM
string name = vm["ElementName"].ToString();
// Create Settings
ManagementObject vmSettings = hyperv.GetVirtualSystemSettingData(this.name, vm["__PATH"].ToString());
// Get VM Settings
ManagementBaseObject inParams = vsms.GetMethodParameters("GetSummaryInformation");
inParams["SettingData"] = new string[1] { vmSettings["__PATH"].ToString() };
// Request CPU Information
inParams["RequestedInformation"] = new int[4] { 4, 100, 101, 103 };
ManagementBaseObject outParams = vsms.InvokeMethod("GetSummaryInformation", inParams, null);
ManagementBaseObject[] value = (ManagementBaseObject[])outParams.GetPropertyValue("SummaryInformation");
UInt16 state = (UInt16)value[0].GetPropertyValue("EnabledState");
numberOfProcs += (UInt16)value[0].GetPropertyValue("NumberOfProcessors");
ReportMetric($"vms/{name}/numberofprocessors", "procs", (UInt16)value[0].GetPropertyValue("NumberOfProcessors"));
if (state == 2)
{
processorLoad += (UInt16)value[0].GetPropertyValue("ProcessorLoad");
ReportMetric($"vms/{name}/processorload", "percent", (UInt16)value[0].GetPropertyValue("ProcessorLoad"));
memoryUsage += (UInt64)value[0].GetPropertyValue("MemoryUsage");
ReportMetric($"vms/{name}/memoryused", "mibibytes", (UInt64)value[0].GetPropertyValue("MemoryUsage"));
}
// Cleanup
inParams.Dispose();
outParams.Dispose();
vmSettings.Dispose();
}
vsms.Dispose();
// Report Host Metrics
ReportMetric($"host/numberofprocessors", "procs", numberOfProcs);
ReportMetric($"host/processorload", "percent", processorLoad);
ReportMetric($"host/vms/memoryused", "mibibytes", memoryUsage);
ReportMetric($"host/vms/memoryused", "percent", (float)(((Decimal)(memoryUsage * 1048576) / (Decimal)hostCapacityBytes) * 100));
}
开发者ID:beyondcomputing-org,项目名称:NewRelic.HyperV,代码行数:54,代码来源:PluginAgent.cs
示例15: ReportReplicationHealth
private void ReportReplicationHealth(ManagementObjectCollection vms)
{
// Create Host metrics
int hostReplicationHealth = 0;
foreach (ManagementObject vm in vms)
{
// Name of VM
string name = vm["ElementName"].ToString();
// Get Replication Mode
hyperv.NewRelicMetric ReplicationMode;
ReplicationMode = hyperv.GetReplicationMode(vm);
// Get Replication Health Status
hyperv.NewRelicMetric ReplicationHealth;
ReplicationHealth = hyperv.GetReplicationHealth(vm);
hostReplicationHealth += (int)ReplicationHealth.Metric;
if (ReplicationMode.Metric == 1)
{
// Primary Replication Node
log.Info($"Primary Node {name} - Health: {ReplicationHealth.Description}");
ReportMetric($"replication/primary/{name}/health", "errors", ReplicationHealth.Metric);
}
else if (ReplicationMode.Metric != 0)
{
// Secondary Replication Node
log.Info($"Secondary Node {name} - Health: {ReplicationHealth.Description}");
ReportMetric($"replication/secondary/{name}/health", "errors", ReplicationHealth.Metric);
}
}
// Report Host Metrics
ReportMetric($"host/vms/replicationhealth", "errors", hostReplicationHealth);
}
开发者ID:beyondcomputing-org,项目名称:NewRelic.HyperV,代码行数:36,代码来源:PluginAgent.cs
示例16: ReportVMHealth
private void ReportVMHealth(ManagementObjectCollection vms)
{
// Create Host metrics
int vmErrors = 0;
foreach (ManagementObject vm in vms)
{
// Name of VM
string name = vm["ElementName"].ToString();
// Health of VM
hyperv.NewRelicMetric HealthMetric;
HealthMetric = hyperv.GetHealthState(vm);
vmErrors += (int)HealthMetric.Metric;
ReportMetric($"vms/{name}/health", "errors", HealthMetric.Metric);
}
// Report Host Metrics
ReportMetric($"host/vms/health", "errors", vmErrors);
}
开发者ID:beyondcomputing-org,项目名称:NewRelic.HyperV,代码行数:20,代码来源:PluginAgent.cs
示例17: ReportVMUptime
private void ReportVMUptime(ManagementObjectCollection vms)
{
foreach (ManagementObject vm in vms)
{
// Name of VM
string name = vm["ElementName"].ToString();
// Uptime of VM
UInt64 UpTimeDays = UInt64.Parse(vm["OnTimeInMilliseconds"].ToString()) / (1000 * 60 * 60 * 24);
UInt64 UpTimeHours = UInt64.Parse(vm["OnTimeInMilliseconds"].ToString()) / (1000 * 60 * 60);
UInt64 UpTimeMinutes = UInt64.Parse(vm["OnTimeInMilliseconds"].ToString()) / (1000 * 60);
ReportMetric($"vms/{name}/UpTimeInDays", "Days", UpTimeDays);
ReportMetric($"vms/{name}/UpTimeInHours", "Hours", UpTimeHours);
ReportMetric($"vms/{name}/UpTimeInMinutes", "Minutes", UpTimeMinutes);
}
}
开发者ID:beyondcomputing-org,项目名称:NewRelic.HyperV,代码行数:17,代码来源:PluginAgent.cs
示例18: NTLogEventCollection
public NTLogEventCollection(ManagementObjectCollection objCollection)
{
privColObj = objCollection;
}
开发者ID:navkar,项目名称:BizTalkControlCenter,代码行数:4,代码来源:NTLogEvent.cs
示例19: BcdObjectCollection
public BcdObjectCollection(ManagementObjectCollection objCollection)
{
privColObj = objCollection;
}
开发者ID:dgrapp1,项目名称:WindowsSDK7-Samples,代码行数:4,代码来源:ROOT.WMI.BcdObject.cs
示例20: BcdObjectEnumerator
public BcdObjectEnumerator(ManagementObjectCollection.ManagementObjectEnumerator objEnum)
{
privObjEnum = objEnum;
}
开发者ID:dgrapp1,项目名称:WindowsSDK7-Samples,代码行数:4,代码来源:ROOT.WMI.BcdObject.cs
注:本文中的System.Management.ManagementObjectCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论