SDK Resources > C# CIM Framework API > "Not Typed" Example

"Not Typed" Example

This example performs the same function as the strong typing example.

Untyped functions require text versions of the class name, field names, and field values. Further, the CimObject returns text field names and values.

The generated classes know the resource URI for the class. The untyped functions require supplying the URI explicitly.

// Define resourceUri of the object to receive

Uri resourceUri = new Uri("http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PhysicalMemory");

The example requests an Enumerate of the class identified in the URI. This request will return not only all instances of CIM_PhysicalMemory, but any objects that inherit from CIM_PhysicalMemory. In this way it is possible to retrieve information without knowing the name of the inheriting objects.

// Receive all object with the required resourceUri

List<CimObject> physicalMemoryList = CimObject.Enumerate(wsmanClient, resourceUri);

 

int itemIndex = 0;

// Loop over all the objects.

foreach (CimObject mem in physicalMemoryList)

{

    string res = String.Empty;

    List<KeyValuePair<string, string>> properties = mem.Properties;

    foreach (KeyValuePair<string, string> property in properties)

    {

        res += property.Key + ": " + property.Value + "\n";

    }

    // Print the values of each CIM_PhysicalMemory

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

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

    Console.WriteLine(res);

 

    itemIndex++;

}

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