SDK Resources > C# CIM Framework API > Strong Typing Example

Strong Typing Example

This example retrieves instances of CIM_PhysicalMemory and displays the fields in each instance.

First, the WS-Management client wrapper is configured with the parameters that define the Intel AMT device to be addressed:

wsmanClient = new DotNetWSManClient(ip, username, password, secure, kerberos, clientCert, HttpProxy);

The example enumerates objects that correspond to the physical memory in the platform using the Enumerate function in the CIM_PhysicalMemory generated class that inherits from a CimBase static function:

 

// Receive all instances of CIM_PhysicalMemory

List<CIM_PhysicalMemory> physicalMemory = CIM_PhysicalMemory.Enumerate(wsmanClient);

Each instance of CIM_PhysicalMemory returned is scanned for fields based on the field name. The example uses the values found to build a string for subsequent display. The example then displays the values.

int itemIndex = 0;

// Loop over all CIM_PhysicalMemory

foreach(CIM_PhysicalMemory mem in physicalMemory)

{

    String res = String.Empty;

    if (mem.CapacityExist)

        res += "Capacity: " + mem.Capacity + "\n";

    if (mem.FormFactorExist)

        res += "Form Factor: " + mem.FormFactor + "\n";

    if (mem.MemoryTypeExist)

    {

        res += "Memory Type: ";

        switch (mem.MemoryType)

        {

            case 0:

                res += "Unknown \n";

                break;

            case 1:

                res += "Other \n";

                break;

            case 2:

                res += "DRAM \n";

                break;

            default:

                break;

        }

    }

    if (mem.SpeedExist)

        res += "Speed: " + mem.Speed + "\n";

    if (mem.ManufacturerExist)

        res += "Manufacturer: " + mem.Manufacturer + "\n";

    if (mem.SerialNumberExist)

        res += "Serial Number: " + mem.SerialNumber + "\n";

    // This property is a key, so the object must contain this field.

    res += "Tag: " + mem.Tag + "\n";

   

    if (mem.PartNumberExist)

        res += "PartNumber: " + mem.PartNumber + "\n";

    Console.WriteLine("\n Item #{0}", itemIndex);

    Console.WriteLine("-------------------------------");

    Console.WriteLine(res);

    itemIndex++;

}

Copyright © 2006-2013, Intel Corporation. All rights reserved.