2
我有一个System.Activities.Statements.InvokeMethod
活动。我试图用激活它如何在InvokeMethod工作流程中使用扩展方法?
TargetType: (null)
TargetObject: licxFiles //an ICollection<string>
MethodName: StoreIfHasValue
的StoreIfHasValue
:
public static void StoreIfHasValue(this ICollection<string> collection, string value)
{
if (value.IsNullOrEmpty()==false)
collection.Add(value);
}
我从工作流设计器通过唯一的参数是:
Direction: In
Type: String
Value: LicxUtilities.CheckForLicx(projectPath,doc)
CheckForLicx
:
public static string CheckForLicx(string projPath, XDocument proj)
{
var ns=proj.Root.Name.Namespace;
var q = from refs in proj.Root.Elements(ns+"ItemGroup").Descendants(ns+"EmbeddedResource")
where refs.Attribute("Include").Value.EndsWith(".licx", StringComparison.CurrentCultureIgnoreCase)
select refs.Attribute("Include").Value;
var licx=q.FirstOrDefault(); //assume there is only one .licx file reference in the project
if (licx.IsNullOrEmpty())
return null;
return System.IO.Path.Combine(projPath, licx);
}
是我使用方法调用作为参数的问题?或者为什么这给错误
'ICollection`1' does not have a public instance method named 'StoreIfHasValue' matching the parameter types, generic type arguments, and generic type constraints supplied to InvokeMethod 'Check for and store'.
啊,所以假装它不是扩展方法。我会给它一个镜头。 – Maslow 2010-07-26 18:49:44