Creating an Application Development Framework Using Enterprise Templates - Part 3, Page 2
Customizing the Development Environment
In this section, we will see how to customize the development environment so that the developers don't have to spend trying to determine which options to use.
Setting default constraint for toolbox items
In this section, we will see how to set default property value for the EventLog component. You might recall that in our application we always log exceptions or informational messages using a specific event source. This is very handy because we can use the event source to uniquely identify all the exceptions that are logged from our application. We can enforce this in our application by creating a PropertyConstraint that pre-sets the event source property value of the EventLog component (that is available under the Toolbox->Components tab) to ExceptionManagerPublishedException. Once this is done, any time a developer tries to add the EventLog component to the application, the event source property will be automatically set to ExceptionManagerPublishedException and it will be read-only. We can accomplish this by adding the following entries to the CustomDistributedAppTemplate.tdl file.
<ELEMENT> <ID>codeComponentsEventLog</ID> <IDENTIFIERS> <IDENTIFIER> <TYPE>CODEVARIABLE</TYPE> <IDENTIFIERDATA> <NAME>TYPENAME</NAME> <VALUE>System.Diagnostics.EventLog</VALUE> </IDENTIFIERDATA> </IDENTIFIER> </IDENTIFIERS> <FEATURELINKS> <TOOLBOXLINKS> <TOOLBOXLINK>tboxComponentsEventLog</TOOLBOXLINK> </TOOLBOXLINKS> </FEATURELINKS> <CONSTRAINTS> <PROPERTYCONSTRAINTS> <PROPERTYCONSTRAINT> <NAME>Source</NAME> <READONLY>1</READONLY> <DEFAULT>ExceptionManagerPublishedException</DEFAULT> </PROPERTYCONSTRAINT> </PROPERTYCONSTRAINTS> </CONSTRAINTS> </ELEMENT>
Page 2 of 4