In This Article

Document Properties

The ICodeDocument.Properties property provides a dictionary-like object that can store any sort of custom data that should be associated with the document.

The property returns an PropertyDictionary object, which supports any object type as a key or value.

Storing Data

In this code snippet we store an object referenced by the variable someObject into the properties dictionary under the string key "MyPropertyKey":

document.Properties["MyPropertyKey"] = someObject;

Retrieving Data

In this code snippet we retrieve an object stored under the string key "MyPropertyKey":

object someObject;
if (document.Properties.TryGetValue("MyPropertyKey", out someObject)) {
	...
}

Alternatively the indexer could be used, however it will throw an exception if there is no object stored with the specified key, whereas TryGetValue will not.