Home Page › Forums › BizTalk 2004 – BizTalk 2010 › null/nil values for a custum functoid
- This topic has 1 reply, 1 voice, and was last updated 9 years, 6 months ago by
community-content.
-
AuthorPosts
-
-
February 2, 2007 at 5:12 AM #17529
Hi,
I just tried to create a custom functoid like the coalesce function in SQL. A function returning the first non-null value. But I experience the following problem: When I connect strings, it works fine, but if I connect a value mapper my function as a parameter, and the value mapper does not result in a value, my function does not return any value, even if another parameter to my function has a value. What does the value mapper generate on false? nil? nothing? it seems that the function afterwards is not called at all.
Any ideas?
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.BizTalk.BaseFunctoids;
using System.Reflection;namespace TTBiztalkFunctoids
{
public class CoalesceFunctoid : BaseFunctoid
{
public CoalesceFunctoid()
: base() {this.ID = 7000;
this.Category = FunctoidCategory.String;// this to get the resources embedded in the resx file,
// call GetExecutingAssembly because the resource is compiled and embedded into the DLL.
SetupResourceAssembly("TTBiztalkFunctoids.Resources", Assembly.GetExecutingAssembly());SetDescription("Coalesce_Description");
SetTooltip("Coalesce_Tooltip");
SetBitmap("Coalesce_Icon"); // must be an embedded BITMAP, not icon!!!
SetName("Coalesce_Name");
AddScriptTypeSupport(ScriptType.CSharp);//this function can accept variable inputs. The overidden function "GetInlineScriptBuffer" will
//provide inline script code for various number of inputs.
this.HasVariableInputs = true;//Set the minimum number of parameters to be 1
this.SetMinParams(1);//// this method call tells the mapper what function to call, when functoid is deployed to GAC.
//SetExternalFunctionName(GetType().Assembly.FullName,
// "TTBiztalkFunctoids.Coalesce", "Coalesce");// define output and input connection types..
this.OutputConnectionType = ConnectionType.AllExceptRecord;
AddInputConnectionType(ConnectionType.AllExceptRecord);}
//this overidden function provides inline code for various number of inputs.
protected override string GetInlineScriptBuffer(ScriptType scriptType, int numParams, int functionNumber) {
if (ScriptType.CSharp == scriptType) {
StringBuilder builder = new StringBuilder();builder.Append("public string Coalesce(");
for (int i = 0; i < numParams; i++) {
if (i > 0) {
builder.Append(", ");
}builder.Append("string param");
builder.Append(i.ToString());
}builder.Append(")\n");
builder.Append("{\n");builder.Append(" System.Collections.ArrayList listStrings = new System.Collections.ArrayList();\n");
for (int j = 0; j < numParams; j++) {
builder.Append(" listStrings.Add(param");
builder.Append(j.ToString());
builder.Append(");\n");
}builder.Append(" foreach (string s in listStrings)\n");
builder.Append(" {\n");
builder.Append(" if (s!=null)\n");
builder.Append(" {\n");
builder.Append(" return s;\n");
builder.Append(" }\n");
builder.Append(" }\n");
builder.Append(" return null;\n");
builder.Append("}\n");return builder.ToString();
} else {
return "";
}
}//public string Coalesce(params string[] inputs) {
// foreach (string input in inputs) {
// if (input != null) return input;
// }
// return null;
//}
}}
-
February 2, 2007 at 8:47 AM #17532
make sure the logical is the FIRST parameter in your value mapper.
– wa
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.