This project is read-only.

Create a Host

CCI Metadata

The CCI libraries are not associated with any particular application environment. From a CCI perspective, issues such as file locations or the targeted .NET version are matters of application policy. An application host object handles the details of implementing application policies and presents the results to CCI through a standard interface.

CCI Metadata includes a standard host object, Microsoft.Cci.PeReader.DefaultHost, which is sufficient for many applications, including HelloIL. DefaultHost is implemented as a nested class in the Microsoft.Cci.PeReader class. HelloIL creates an instance of DefaultHost, as follows:
MetadataReaderHost host = new PeReader.DefaultHost( )
NameTable nameTable = host.NameTable;

For details, see Hosts.

When you create a host by using the default constructor, as shown in the example, the host creates a Microsoft.Cci.NameTable and assigns it to the NameTable property. NameTable is a utility object that is used by the host and other members of the CCI Metadata library to improve string-comparison performance. NameTable contains a table of key-value pairs, each of which consists of a string and a unique integral key. You can thus test string equality by comparing keys instead of going through the strings character-by-character.

For more details, see The NameTable Object.

After the NameTable object is created, you add appropriate strings by passing each one to NameTable.GetNameFor. This method creates a unique key for the string, stores the data, and returns the key-value pair as a Microsoft.Cci.IName interface. If the string is already in the table, GetNameFor simply returns the key-value pair. You usually pass names or other strings to CCI Metadata methods in the form of an IName interface, obtained by calling GetNameFor.

For more details, see The IName Interface.

Next: Create and Configure an Assembly Object
Return to Beginning

Last edited Dec 18, 2009 at 9:20 PM by Guy_Smith, version 2


No comments yet.