SDK Resources > C# CIM Framework API > Strongly Typed and Untyped

Strongly Typed and Untyped

The C# CimFramework enables development of two kinds of applications: those that depend on strong typing and those that expect an interface where details of the CIM class specifications are not built in.

Strong Typing

The C# CimFramework implements strong typing with automatically generated C# classes tied to the definitions in the MOFs. Applications that use the generated classes bind to the CIM class structure at compile time. The compiler can validate the correctness of the code based on the structures defined in the MOFs. The C# CimFramework includes a C# interface for each class supported by Intel AMT, derived from the MOF and the CimBase class in the framework. As shown below, these classes give the implementer access to all methods associated with the CIM class. Invoking a method in one of these classes accesses the internal XML document associated with the class. For example, a Create method builds the serialized XML for the object that the application creates. The C# CimFramework then invokes the dotNetWsManClient to send the Create request.

The advantage of strong typing is that the program’s correctness is checked at compile time. The disadvantage is that the generated C# class is based on a specific version of the MOF, which can be a limitation when MOFs vary between releases of the DMTF standard or of Intel AMT.

Generated C# Classes

The Intel AMT SDK provides a C# class that implements each CIM class supported by Intel AMT. Each class is generated based on the corresponding MOF plus other implementation dependent information.

The generated classes implement all of the valid methods in the class. The generated classes inherit from the CimBase class.

Each generated class has a pair of functions for each field defined as optional in the MOF.

   <fieldname>Exist returns true if the optional field is present in the current instance of this object type that was retrieved from Intel AMT (for example, with a Get operation).

   <fieldname>Remove   removes the optional field from the current object before sending it to Intel AMT (for example, with a Put operation). This method will succeed only if this field is optional in the concrete object.

All of the C# samples in the SDK demonstrate how to work with the generated C# classes.

Untyped

An application using an interface where the CIM class definitions are not built in is “untyped”. Such an application does not have built-in a priori knowledge of the MOF structure. The application provides text values for field names, method names and parameters. An application can Get an object and then receive field/value string pairs associated with the object. The CimObject class provides the mechanisms used for applications that do not need strong typing.

This approach is used in scripting applications that have definitions included in them in the form of strings (for example, URIs, field names, and special methods). The strings are validated only at runtime, when Intel AMT will return an error status when an incorrect value is used. A disadvantage of the untyped approach is that it is impossible to discover any special methods associated with a class.

A Unified Approach

The strong typing approach is built upon the untyped mechanism: The generated classes for each CIM class inherit from the CimBase abstract class in C# CimFramework. The methods in the generated classes use the same serialized XML document. When a method in one of these classes sends values to Intel AMT, the framework converts the method name and field names to strings and provides their values to the CimObject class, which then embeds the results in the XML document.

 Note:

The contents of fields provided as inputs need to be correct. The framework may throw an exception when a field has a character that is invalid in the context of an XML field.

 

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