Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Model Extensions

Retired Content

The Web Service Software Factory is now maintained by the community and can be found on the Service Factory site.

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Retired: November 2011

The Web Service Software Factory includes a DSL framework extension that implements a mechanism to add selectable sets of properties to existing model elements without having to modify the DSL designers. Because the mechanism was initially created to add technology-specific properties to service contract elements, it is most often referred to as the Technology Extensions.

Figure 1 illustrates a logical view of that mechanism.

Ff699429.e90cd90c-64af-44c6-a1ce-4c44f2d9cd0e(en-us,PandP.10).png

Figure 1

Logical view of the model extension mechanism

For a model element to be extended, it must implement the IExtensibleObject interface, defined in the Microsoft.Practices.Modeling.Common project in the Libraries solution folder.

The IExtensibleObject interface defines an array of ObjectExtenders and a property that holds a reference to one of those objects, which is the currently selected extender. ObjectExtender is a container of additional (extension) properties on a model element. The following are the differences between the regular properties defined in the model and the extension properties:

The regular properties are always shown in the Properties window when the model element is selected.

Only the properties of the currently selected ObjectExtender are show in the Properties window.

In the Service Factory, all ObjectExtender classes are placed in the projects of the Extenders solution folder, and then they are copied with their assemblies to the Lib folder during the build process. This permits the Service Factory runtime to find them there at run time by using the AssemblyLoader. A model element does not contain information about which extenders can be assigned to it. It is the extenders that know what model element type they apply to. The next code example is a fragment of the WCFService extender. The ObjectExtender attribute and the generic abstract base class ObjectExtender<Service> define it as the extension to the Service model element defined in the Service Contract model. The following code shows the details of only one extension property, called ConcurrencyMode.

[Serializable]
[CLSCompliant(false)]
[ObjectExtender(typeof(Service))]
public class WCFService : ObjectExtender<Service>
{
private ConcurrencyMode concurrencyMode;
private InstanceContextMode instanceContextMode;
#region Constructors
… 
#endregion

#region Properties
[Category(ServiceContractWCFExtensionProvider.ExtensionProviderPropertyCategory),
Description("Specifies whether a service supports single-threaded or multi-threaded modes of operation."),
ReadOnly(false),
Browsable(true)]
[XmlElement("ConcurrencyMode")]
public ConcurrencyMode ConcurrencyMode
{
get { return concurrencyMode; }
set { concurrencyMode = value; }
}
…
#endregion
} 

The ExtensionProvider is a class that provides a list of applicable extender types. The Service Factory has two extension providers: one for the WCF extenders of the Service Model (ServiceContractWCFExtensionProvider) and one for the ASMX extenders of the same model (ServiceContractAsmxExtensionProvider). Both of these extenders are associated with the root model element of the Service Contract model.

The ServiceContractModel implements the ITechnologyProvider interface, which provides the currently selected ExtensionProvider for the model. The logic of creating and associating extender instances with the Service Contract model elements is implemented in the property editor of the ImplementationTechnology property of the ServiceContractModel element. The editor class is named ExtensionProviderEditor and is in the Microsoft.Practices.Modeling.ExtensionProvider project in the Libraries solution folder. The editor is called when the user is selecting the implementation technology of the entire service contract diagram (a necessary step before code can be generated).

When a model is saved, the extenders associated with its model elements are saved together with those elements. When a model is loaded, the extenders are loaded and attached to the extended model element.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.