2. Schema Selection in VS .NET Designer
The property MyDocSpec in the previous section's MyProber class is actually of type SchemaWithNone. SchemaWithNone
is a class that lives in the Microsoft.BizTalk.Component. Utilities.dll
assembly. Defining a property of type SchemaWithNone will give the user
a drop-down list of all deployed schemas within the current BizTalk
Management Database. The class has one public constructor, SchemaWithNone, which initializes a new instance of the SchemaWithNone class. Tables 1 and 2 list the public properties and methods of the class.
Table 1. SchemaWithNone Public Properties
Property | Description |
---|
AssemblyName (inherited from Schema) | Gets or sets the schema assembly name |
DocSpecName (inherited from Schema) | Gets or sets the document spec name for the selected schema |
RootName (inherited from Schema) | Gets or sets the root node of the selected schema |
SchemaName (inherited from Schema) | Gets or sets the selected schema name |
TargetNamespace (inherited from Schema) | Gets or sets the target namespace of the selected schema |
Table 2. SchemaWithNone Public Methods
Method | Description |
---|
Equals (inherited from Schema) | Overridden. Determines whether the specified Object is equal to the current Object. |
GetHashCode (inherited from Schema) | Overridden. Returns the hash code for this instance. |
GetType (inherited from System.Object) | For additional information about the System namespace, see the .NET Framework documentation available from Visual Studio .NET or online at http://go.microsoft.com/fwlink/?LinkID=9677. |
ToString (inherited from Schema) | Overridden. Converts the value of this instance to its equivalent string representation using the specified format. |
As you can see in Figure 1, the properties for the SchemaWithNone class are available in the IDE. If you notice the InboundDocSpec property, it is a list of all the schemas that are currently deployed to the BizTalk solution. The SchemaWithNone
property allows you to select one and only one schema from the deployed
schemas, and this information will be used to populate the properties
of the object as defined previously (AssemblyName, DocSpecName, and so on).
In the example from the
preceding section, you want your developer to select only one schema,
but what if your developer needs multiple schemas, for example, to
handle different message formats in one component? In many cases, your
component will be able to handle a variety of schemas; in this case, you
need to use the SchemaList property.
In the case where your property needs to select multiple schemas, you need to use the SchemaList
object. Such an object will provide developers with an associate window
from which they can choose multiple schemas. The selected schemas will
be available as a collection of schemas within a main class. The IDE
will present the screen shown in Figure 2.
2.1. Decorating Your Properties
It is important to
consider the usability of your components from within the Visual Studio
IDE. If you simply expose a public property from within your pipeline
component, two things will happen. First, the property name that is
displayed in the IDE will be the name of the property . Second, there is no public description for what the
property actually does. In order to make your components usable, you can
use custom attributes to decorate your properties with metadata so that
the developer experience is improved. The two main attributes you can
use to do this are described next.
2.1.1. Using the DisplayName and Description Attributes
The DisplayName attribute allows you to set the name for the property that will be displayed in the IDE. The Description attribute sets the description box within the VS .NET designer to a friendly description. Figure 3 shows the effect of these attributes. The following code snippet demonstrates how these attributes are to be used:
'<summary>
'this property will contain a single schema
'</summary>
<Description("The inbound request document specification. Only messages of this _
type will be accepted by the component.")> _
<DisplayName("Inbound Specification")> _
Public Property InboundFileDocumentSpecification() As _
Microsoft.BizTalk.Component.Utilities.SchemaWithNone
Get
Return _InboundFileDocumentSpecification
End Get
Set(ByVal Value As Microsoft.BizTalk.Component.Utilities.SchemaWithNone)
_ InboundFileDocumentSpecification = Value
End Set
End Property