Custom adapter with custom Editor

Home Page Forums BizTalk 2004 – BizTalk 2010 Custom adapter with custom Editor

Viewing 1 reply thread
  • Author
    Posts
    • #18137

      Hi,

      I want to create a custom editor for my custom adapter. The Adapter framework creates an editor automatically (a list of properties using categories, description, etc.). I can create a custom editor for a specific property but how can I create a whole new editor. Just like the editors for FILE or FTP?

      Thanks for any help,

      Dashiel
       

    • #18144

      Dashiel,

      AFAIK, those kind of fully customized editors are only available to unmanaged adapters (yes, several of the native adapters shipping with biztalk are still written in unmanaged code, such as the FILE and SMTP adapters). However, for managed adapters you can still tweak quite a bit of what you get with the default property grid based property dialog (including adding a popup WInForms dialog when you edit a specific property which can have anything you want in it).

      • #18149

        Hi,
         
        Thanks for the reply. Not what I wanted to hear 🙂 but at least I don't have to search for it any more.

        The reason why I wanted to use this is because I had a problem with empty property values as I don't want to use the context menu to "Nullify" the property. I found a nice workaround though and therefore post it here:

        This a converter that converts an empty value (user input) into a empty-placeholder-string (datastorage) when a user enters a value (and the other way around for display the value). In the adaptercode the value must be checked for this placeholder to reset it to string.Empty.

        This is the reference in the schema: 

        <xs:element name="ConfigDBStoredProcedure" type="xs:string">
            <xs:annotation>
                <xs:appinfo>
                    <baf:designer xmlns:baf="BiztalkAdapterFramework.xsd">
                        <baf:displayname _locID="ConfigDBStoredProcedureName">Edit this field in the resource file</baf:displayname>
                        <baf:description _locID="ConfigDBStoredProcedureDesc">Edit this field in the resource file</baf:description>
                        <baf:category _locID="ConfigDB"></baf:category>
                        <baf:converter>ASSEMBLY.EmptyPlaceholderConverter, AdapterUIEditors, Version=1.0.0.0, Culture=neutral, PublicKeyToken=…, processorArchitecture=MSIL</baf:converter>
                    </baf:designer>
                </xs:appinfo>
            </xs:annotation>
        </xs:element>
         

        This is the addionaly class:

        using System;
        using System.Collections.Generic;
        using System.Text;
        using System.ComponentModel;
        using System.Diagnostics;

        namespace GlobalRefund.B2B.DeepFileAdapter.UIEditors
        {
            public class EmptyPlaceholderConverter : TypeConverter
            {
                public const string EmptyPlaceholder = "!!##EmptyPlaceholder##!!";

                // From input to datastorage
                public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
                {
                    EventLog.WriteEntry("EmptyToNullConverter", "ConvertFrom " + (value == null ? "null" : value.ToString()) + " " + value.GetType().ToString());
                    if (value is string && (string)value == string.Empty) return EmptyPlaceholder;
                    return value;
                }

                // from datastorage to input
                public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
                {
                    EventLog.WriteEntry("EmptyToNullConverter", "ConvertTo " + (value == null ? "null" : value.ToString()));
                    if (value == null || (value is string && (string)value == EmptyPlaceholder)) return string.Empty;
                    return value;
                }
            }
        }

        And this is the usage in the adapter:

        string rootFolder = Extract(document, "Config/RootFolder");
        if (rootFolder == EmptyPlaceholderConverter.EmptyPlaceholder) rootFolder = string.Empty; 

         

        hope this helps others with the same problem 🙂
         

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.