BizTalk 2009 - Creating a Custom Functoid Library

Posted by StuartBrierley on Geeks with Blogs See other posts from Geeks with Blogs or by StuartBrierley
Published on Wed, 26 May 2010 11:39:06 GMT Indexed on 2010/05/26 12:51 UTC
Read the original article Hit count: 376

Filed under:

If you find that you have a need to created multiple Custom Functoids you may also choose to create a Custom Functoid Library - a single project containing many custom functoids.  As previsouly discussed, the Custom Functoid Wizard can be used to create a project with a new custom functoid inside.  But what if you want to extend this project to include more custom functoids and create your Custom Functoid Library? 

First create a Custom Functoid Library project and your first Custom Functoid using the Custom Functoid Wizard.

When you open your Custom Functoid Library project in Visual Studio you will see that it contains your custom functoid class file along with its resource file.  One of the items this resource file contains is the ID of the the custom functoid.  Each custom functoid needs a unique ID that is over 6000.  When creating a Custom Functoid Library I would first suggest that you delete the ID from this resource file and instead create a _FunctoidIDs class containing constants for each of your custom functoids.  In this way you can easily see which custom functoid IDs are assigned to which custom functoid and which ID is next in the sequence of availability:

namespace MyCompany.BizTalk.Functoids.TestFunctoids

{
    class _FunctoidIDs
    {
        public const int TestFunctoid                       = 6001;
    }
}

You will then need to update the base() function in your existing functoid class to reference these constant values rather than the current resource file.

From:

   int functoidID;
   // This has to be a number greater than 6000
   functoidID = System.Convert.ToInt32(resmgr.GetString("FunctoidId"));
   this.ID = functoidID;

To:

this.ID = _FunctoidIDs.TestFunctoid;


To create a new custom functoid you can copy the existing custom functoid, renaming the resultant class file as appropriate.  Once it is renamed you will need to change the Class name, ResourceName reference and Base function name in the class code to those of your new custom functoid.  You will also need to create a new constant value in the _FunctoidIDs class and update the ID reference in your code to match this. 

Assuming that you need some different functionalty from your new  customfunctoid you will need to check or amend the following in your functoid class file:

  • Min and Max connections
  • Functoid Category
  • Input and Output connection types
  • The parameters and functionality of the Execute function

To change the appearance of you new custom functoid you will need to check or amend the following in the functoid resource file:

  • Name
  • Description
  • Tooltip
  • Exception
  • Icon

You can change the String values by double clicking the resource file and amending the value fields in the string table.

To amend the functoid icon you will need to create a 16x16 bitmap image.  Once you have saved this you are then ready to import it into the functoid resource file.  In Visual Studio change the resource view to images, right click the icon and choose import from file.

You have now completed your new custom functoid and created a Custom Functoid Library.  You can test your new library of functoids by building the project, copying the resultant DLL to C:\Program Files\Microsoft BizTalk Server 2009\Developer Tools\Mapper Extensions and then resetting the toolbox in Visual Studio.
 

© Geeks with Blogs or respective owner