mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 12:30:50 +01:00
CP-36392: Refactor for loop into if statement
For loop acts as if statement. Changed to address static analysis flag. Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
parent
2d1e6dcb92
commit
c9e65a3000
@ -486,10 +486,16 @@ namespace XenOvf
|
||||
try
|
||||
{
|
||||
searcher = new ManagementObjectSearcher(@"select * from Win32_ComputerSystem");
|
||||
foreach (ManagementObject mgtobj in searcher.Get())
|
||||
var mgtObjs = searcher.Get();
|
||||
|
||||
// only want one.
|
||||
if (mgtObjs.Count > 0)
|
||||
{
|
||||
Win32_ComputerSystem = mgtobj; // only want one.
|
||||
break;
|
||||
using (var iterator = mgtObjs.GetEnumerator())
|
||||
{
|
||||
iterator.MoveNext();
|
||||
Win32_ComputerSystem = (ManagementObject) iterator.Current;
|
||||
}
|
||||
}
|
||||
log.Debug("OVF.CollectionInformation Win32_ComputerSystem.1");
|
||||
}
|
||||
@ -511,11 +517,18 @@ namespace XenOvf
|
||||
try
|
||||
{
|
||||
searcher = new ManagementObjectSearcher(@"select * from Win32_Processor");
|
||||
foreach (ManagementObject mgtobj in searcher.Get())
|
||||
var mgtObjs = searcher.Get();
|
||||
|
||||
// only want one.
|
||||
if (mgtObjs.Count > 0)
|
||||
{
|
||||
Win32_Processor.Add(mgtobj); // only want one.
|
||||
break;
|
||||
using (var iterator = mgtObjs.GetEnumerator())
|
||||
{
|
||||
iterator.MoveNext();
|
||||
Win32_Processor.Add((ManagementObject) iterator.Current);
|
||||
}
|
||||
}
|
||||
|
||||
log.DebugFormat("OVF.CollectionInformation Win32_Processor.{0}", Win32_Processor.Count);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user