Technology Extensions

Technology Extensions can be used in conjunction with a model to describe additional properties or perform additional tasks. The information contained by the Technology Extension is interfaced in the same way as any other property of a Model or Model Element. The difference with regular model properties is that the choice for a specific technology extension can be postponed until the moment of generation. After choosing a Technology Extension, the model and the contents of the extension will be combined into a logical model that can be used to generate code from.

When saving a model, the technology specific information of the Technology Extension is serialized and stored in the Model. This makes it possible for a model to be reused across multiple technologies.


Extending Model Elements

Additional properties that should be specified for a Technology Extension can be provided through an ExtensionProvider. Every ExtensionProvider is registered to a specific model and for every ModelElement contained in the Model it can provide ObjectExtenders that contain represent the added properties at runtime.

ExtensionProviders and ObjectExtenders are registered using their type information. The ExtensionProvider returns a list of Types that contain all the ObjectExtenders. These types are inspected at runtime and mapped to ModelElements based on the ObjectExtender attribute they specify.

In order to extend the properties of a ModelElement, the ModelElement should implement the IExtensibleObject interface. This interface is used to query the ExtenderProvider instance and can be used to persist the extended information as part of the ModelElement.

 [ExtensionProviderAttribute] //Used to specify registration information: ID, Name, Description and Model.
 public class MyExtensionProvider : ExtensionProvider
     //Returns the types for every ObjectExtender that should be provided.
     public List<Type> ObjectExtenders { get }
 [ObjectExtender(typeof(AModelElement))] //Specifies that Model Elements derived from ‘AModelElement’ should be extended
 public class ExtendedModelElement : ObjectExtender<AModelElement>
  public string AddedProperty
  { get; set; }

Object extenders can be used to add Properties to existing ModelElements. They cannot be used to introduce new ModelElements or Relationships between Model Elements.

Extension Providers are registered by adding them to the IExtensionProviderService. This service contains all the ExtensionProviders and can aggregate their ObjectExtenders.

Persisting Extended Properties to a Model

When saving a Model, the ObjectExtenders are saved as part of the ObjectExtenderContainer property. The ObjectExtenderContainer will use a XmlSerializer to serialize and deserialize the ObjectExtenders for each ModelElement.

Interfacing Extended Properties through the Property Grid

The properties declared on a ObjectExtender are shown in the PropertyGrid when a ModelElement of the specified type is selected. This means that the properties can be decorated with attributes from the ComponentModel namespace to interact with the PropertyGrid, for example:

For more information about interacting with the PropertyGrid, you can refer to MSDN.

Adding Technology Specific Recipes

Adding Technology Specific Templates

Packaging and Registering a Technology Extension

incomplete ... for the time being

Last edited May 12, 2007 at 7:51 AM by donsmith, version 2


No comments yet.