Implementing custom connection properties for BizTalk RFID providers

We are working on device providers and came across a situation where we want to add custom connection properties to a device provider.

Those properties should show up here:

Custom properties are called "vendor defined" in this context.
Since the documentation is not quite perfect yet, we think, that this might help some people.

You need to implement this method to provide the custom properties:
public static ProviderMetadata GetProviderMetadata()
where ProviderMetadata is created through the ProviderMetadata constructor:
public ProviderMetadata(ProviderInformation providerInformation,
    Collection<ProviderCapability> capabilities,
   
Dictionary<PropertyKey, RfidProviderPropertyMetadata> providerPropertyMetadata,
    Dictionary
<VendorEntityKey, VendorEntityMetadata> vendorExtensionsEntityMetadata,
    Dictionary
<PropertyKey, RfidDevicePropertyMetadata> devicePropertyMetadata);

The Acme sample provider has some code snippets that demonstrate what is necessary in this context:
Of further interest here are:
public static Collection<ProviderCapability> GetProviderCapabilities()
and
public static Dictionary<VendorEntityKey, VendorEntityMetadata>
                  GetVendorExtensionsEntityMetadata()

In the GetProviderCapabilities pay attention to this line:
    acmeCapability.Add(ProviderCapability.VendorDefinedTransport);

and in the GetVendorExtensionsEntityMetadata please look closer at those lines:
    VendorEntityKey key1 = new VendorEntityKey(
                                   typeof(VendorDefinedTransportSettings),
                                   "CustomAcmeTransportSettings"
                                   EntityType.TransportSettings);
and
    VendorEntityKey key2 = new VendorEntityKey(
                               typeof(VendorDefinedTransportSettings), 
                               "Transport2", EntityType.TransportSettings);

This should give you the necessary information to get it right :)

Code extract from the Acme sample provider:


 

public static ProviderMetadata GetProviderMetadata()

{

    return new ProviderMetadata(

        AcmeProviderMetaData2.ProviderInformation,

        AcmeProviderMetaData2.GetProviderCapabilities(),

        AcmeProviderMetaData2.GetProviderPropertyMetadata(),

        AcmeProviderMetaData2.GetVendorExtensionsEntityMetadata(),

        AcmeProviderMetaData2.GetDevicePropertyGroupMetadata()); ;

}

//...

//not showing the rest here
//... 

/// <summary>

/// Gets the list of capabilites this provider supports.

/// </summary>

/// <returns>List of provider capabilities</returns>

public static Collection<ProviderCapability> GetProviderCapabilities()

{

    List<ProviderCapability> acmeCapability = new List<ProviderCapability>();

 

    acmeCapability.Add(ProviderCapability.Discovery);

    acmeCapability.Add(ProviderCapability.TcpTransport);

    acmeCapability.Add(ProviderCapability.BluetoothTransport);

    acmeCapability.Add(ProviderCapability.HttpTransport);

    acmeCapability.Add(ProviderCapability.SerialTransport);

    acmeCapability.Add(ProviderCapability.VendorDefinedTransport);

    acmeCapability.Add(ProviderCapability.TriggeredDiscovery);

    acmeCapability.Add(ProviderCapability.ProviderDefunctEvent);

 

    return new Collection<ProviderCapability>(acmeCapability);

}


 

/// <summary>

/// Returns meta data for vendor specific entities like command,response etc.

/// </summary>

/// <returns>Dictionary of vendor entity key vs its meta data</returns>

public static Dictionary<VendorEntityKey, VendorEntityMetadata>
                  GetVendorExtensionsEntityMetadata()

{

    Dictionary<VendorEntityKey, VendorEntityMetadata> vendorData 
                = new Dictionary<VendorEntityKey, VendorEntityMetadata>();

 

    //Transport One

    VendorEntityKey key1 = new VendorEntityKey(
                                   typeof(VendorDefinedTransportSettings),
                                   "CustomAcmeTransportSettings"
                                   EntityType.TransportSettings);

 

    Dictionary<string, VendorEntityParameterMetadata> dict 
                         = new Dictionary<string, VendorEntityParameterMetadata>();

    string host = "127.0.0.1";

 

    VendorEntityParameterMetadata dataForHost
                         = new VendorEntityParameterMetadata(typeof(string),

                                       "Enter the host address as a string",

                                       host, false);

    dict.Add("Host", dataForHost);

 

    VendorEntityParameterMetadata dataForPort 
                         = new VendorEntityParameterMetadata(typeof(int),
                                "Enter the port as an int", 6666, false);

    dict.Add("Port", dataForPort);

 

    VendorEntityMetadata metaData1
                         = new VendorEntityMetadata(
                                "VendorDefinedTransportSettings keys", dict);

 

    //Transport two

    VendorEntityKey key2 = new VendorEntityKey(
                               typeof(VendorDefinedTransportSettings), 
                               "Transport2", EntityType.TransportSettings);

 

    Dictionary<string, VendorEntityParameterMetadata> dict2 
                         = new Dictionary<string, VendorEntityParameterMetadata>();

    string property1 = "test1";

 

    VendorEntityParameterMetadata dataForproperty1 
                     = new VendorEntityParameterMetadata(typeof(string),

                            "Enter the host address as a string",

                            property1,

                            false);

    dict2.Add("property1", dataForproperty1);

 

    VendorEntityMetadata metaData2 = new VendorEntityMetadata(
                                            "Transport2 keys", dict2);

 

 

    vendorData.Add(key1, metaData1);

    vendorData.Add(key2, metaData2);

 

    return vendorData;

}

If you "feel" after reading this, that this can be painful, then - well, we are talking about writing device drivers here.

Here is the result in the BizTalk RFID manager:


and


Posted May 02 2007, 09:55 AM by Andreas Erben

Comments

Damir Dobric Posts wrote Rfid Metadata: Creating of the list of entries
on 05-03-2007 0:52

While creating the metadata in DSPI provider sometimes it will be required to provide the list of values,

developers.de is a .Net Community Blog powered by daenet GmbH.