views:

167

answers:

1

I have a System.Activities.Statements.InvokeMethod activity. I'm trying to activate it with

TargetType: (null)
TargetObject: licxFiles //an ICollection<string>
MethodName: StoreIfHasValue

The StoreIfHasValue:

public static void StoreIfHasValue(this ICollection<string> collection, string value)
    {
        if (value.IsNullOrEmpty( )==false)
            collection.Add(value);
    }

The only param I'm passing from the workflow designer is :

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);
    }

Is a problem that I'm using a method call as a param? Or why does this give the error

'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'.
+1  A: 

Never tried this but I suspect you need to treat this as a static method call, which it really is, and pass the object as the first parameter. So empty the TargetObject property and set the TargetType to the class that implements the extension method.

Maurice
ah, so pretend it's not an extension method. i'll give it a shot.
Maslow