Defining design-time properties using basic .NET data types

Posted at: 1/31/2007 at 6:43 PM by saravana

Recently I was building a pipeline component which requires a simple design time property. Even though I've written a white paper about it Understanding Design-Time Properties for Custom Pipeline Components in BizTalk Server I couldn't remeber all the syntax on top of my head. So, I opened the document for a quick view. I just copied a section from the article which explains the basic steps and published it here. View the full article for detailed explanation of some of the advanced concepts.

Let’s start with an example where you need three properties—ConnectionString (string), SaveContext (bool), and LogLevel (enum). To define these properties, you need to perform the following steps within your pipeline component:

Step 1: Define the enumeration type required.

public enum LogLevelType

{

 Warning,

 Error,

 Information

}

Step 2: Define private field variables.

private string _connectionString = string.Empty;

private bool _saveContext = false;

private LogLevelType _logLevel = LogLevelType.Information;

Step 3: Define public design-time properties.

public string ConnectionString

{

get{return _connectionString;}

set{_connectionString = value;}

}

public bool SaveContext

{

get{return _saveContext;}

set{_saveContext = value;}

}

public LogLevelType LogLevel

{

get{return _ logLevel;}

set{ _logLevel = value;}

}

Step 4: Implement the Load method of the IPersistPropertyBag interface.

public virtual void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, int errlog)

       {

            object val = ReadPropertyBag(pb,"ConnectionString");

            if (val != null) _connectionString = (string)val;

            val = ReadPropertyBag(pb, "SaveContext");

            if (val != null) _saveContext = (bool)val;

            val = ReadPropertyBag(pb, "LogLevel");

            if (val != null) _logLevel = (LogLevelType)val;

        }

The helper function ReadPropertyBag is used to read the design-time properties from the property bag.  Error-handling code inside this function is required when the component is loaded inside the pipeline designer for the first time. At that point there are no values associated with the properties, which results in an exception. This helper function catches and suppresses the exception.

Private object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName)

        {

            object val = null;

            try

            {

                pb.Read(propName, out val, 0);

            }

            catch (System.ArgumentException )

            {

                return val;

            }

            catch (System.Exception e)

            {

                throw new System.ApplicationException(e.Message);

            }

            return val;

        }

Step 5: Implement the Save method of the IPersistPropertyBag interface.

public virtual void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, bool fClearDirty, bool fSaveAllProperties)

       {

            object val = _connectionString;

            pb.Write("ConnectionString", ref val);

            val = _saveContext;

            pb.Write("SaveContext", ref val);

            val = (LogLevelType)_logLevel;

            pb.Write("LogLevel", ref val);

        }

Step 6: Implement the GetClassID and InitNew methods of the IPersistPropertyBag interface.

   Public void GetClassID(out System.Guid classid)

        {

            classid = new System.Guid("AC21E483-C9BF-41F1-9AF0-2031528535C6");

        }

The GetClassID method needs to return a unique identifier that represents the component within unmanaged code, which will allow interoperability with unmanaged code.

Note: The BizTalk 2004/2006 messaging engine is built using unmanaged code.

public void InitNew(){}

For basic data types you can leave the InitNew implementation blank, since we don’t have any structure, data, cache, or object to initialize for our sample.  

After you compile the component and insert it into a BizTalk pipeline (see “Using the custom pipeline component within a BizTalk pipeline” later in this article), the properties will be displayed in the property grid as shown in the following figure.

 

Tags: |  Categories: BizTalk General
Actions: Email this article Email | Kick it! | DZone it! | Save to del.icio.us | Technorati Links
Post Information: Permanent LinkPermalink | CommentsComments(9) | Comments RSS

Comments

Thursday, February 08, 2007 4:28 PM
Anonymous
Anonymous
I tried it too ,
in case you are builed custom pipeline it works well , but when you want to configure it on the biztalk administration it shows only simple type and he convert it to integer ....
Thursday, February 08, 2007 5:07 PM
Saravana Kumar
The article got some suggestions on how you can overcome Biztalk Adminstration console limitation to some extend.
Sunday, July 18, 2010 4:25 PM
payday loans
Leadership is a potent combination of strategy and character.
Monday, July 19, 2010 2:22 AM
payday loans
Failing to plan is planning to fail.
Wednesday, July 28, 2010 3:56 PM
faxless payday loans
This is the day upon which we are reminded of what we are on the other three hundred and sixty-four.
Friday, July 30, 2010 8:43 AM
http://www.coachoutletfactory.com
I really like your article, I support your point of view http://www.coach-handbags-outlet.com          coach handbags
Friday, July 30, 2010 1:12 PM
online blackjack
It helped me with ocean of knowledge so I really believe you will do much better in the future I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer!
Friday, August 20, 2010 11:13 AM
Engelhard Prospector
Hey I just want to let you know, I really like the piece of writing on your website. But I am using Flock on a machine running version 8.x of Xubuntu and the design aren't quite right. Not a serious deal, I can still basically read the articles and search for information, but just wanted to inform you about that. The navigation bar is kind of challenging to use with the config I'm running. Keep up the good work!
Sunday, August 22, 2010 6:26 PM
cheapretailjordan
[url=http://www.cheapretailjordan.com]cheap gucci clothing[/url]
[url=http://www.cheapretailjordan.com]Juicy Couture Bikini[/url]
[url=http://www.cheapretailjordan.com]Chanel t shirts[/url]
[url=http://www.cheapretailjordan.com]Christian Audigier Jeans[/url]
[url=http://www.cheapretailjordan.com]Polo t shirt[/url]
[url=http://www.cheapretailjordan.com]ed hardy handbags[/url]
[url=http://www.cheapretailjordan.com]armani jeans[/url]
[url=http://www.cheapretailjordan.com]Coogi Clothing[/url]
[url=http://www.cheapretailjordan.com]Radii ShoeS[/url]
[url=http://www.cheapretailjordan.com]cheap dolce gabbana shoes[/url]

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading