【发布时间】:2017-05-10 16:05:15
【问题描述】:
Microsoft 在 BizTalk Pipeline 界面中提供如下所示的验证组件。
这是我尝试过的,但似乎根本不起作用:
public System.Collections.IEnumerator Validate(object projectSystem)
{
System.Collections.ArrayList errorStringArrayList = new System.Collections.ArrayList();
if (this.Substring1ColumnStart >= this.Substring1ColumnEnd)
{
errorStringArrayList.Add("Substring1ColumnEnd must be > SubstringColumn1Start");
}
return (System.Collections.IEnumerator) errorStringArrayList;
}
说
"这些错误消息显示为编译器错误消息。报告 成功的属性验证,该方法应该返回一个空 枚举器。 "
。
但是当我输入无效值时,我没有收到任何编译器消息。此外,它不会在 BTS-Admin 中进行验证,它不会有“编译器消息”吗???
进一步,为什么 Validate 接收一个泛型对象作为参数而不是强类型参数?什么时候调用验证?每次更改 propertyBag 值时?
2017 年 5 月 11 日上午 11:55 CT 更新
我又尝试了几件事情,其中两件很难在这里一一列举。 我终于得到了一个错误,但在 VS 编译错误中不是一个非常有用的错误,请参见下面的屏幕截图。这绝对不是我返回的错误。也许这在 VS2015 上有问题。
我还遇到了一个问题,我修复了我的数据,但仍然出现错误。由于 Pipeline Componenet 是 GAC 的,我每次都关闭并重新打开 Visual Studio 以确保它获得新副本。
我在想也许返回 null 以外的任何内容都是问题所在。 总之,如果它在 BTS-ADMIN 中不起作用,我发现它实际上毫无用处。所以我只会做运行时错误。也许这就是为什么关于这个主题的文档和文章/博客如此之少的原因。
public System.Collections.IEnumerator Validate(object projectSystem)
{
System.Collections.ArrayList errorStringArrayList = new System.Collections.ArrayList();
if (this.Substring1ColumnStart >= this.Substring1ColumnEnd)
{
errorStringArrayList.Add("Substring1ColumnEnd must be > SubstringColumn1Start");
}
if (errorStringArrayList.Count > 0)
{
return (System.Collections.IEnumerator)errorStringArrayList;
}
else
{
return null;
}
}
【问题讨论】:
-
我已经在 MSDN 上回答了这个问题:social.msdn.microsoft.com/Forums/en-US/…