Michael Herman - Parallelspace

What is the best (only ) way to implement a multi-valued activity parameter

...as a string of delimited values or XML   Is there a better approach

Is something like the following possible

<ns0:ListItem x:Name="ListItem_942c79b7_5a65_4fad_affb_9cd0e362cd84_4" ID="4">
<![CDATA[
"0" "ID" "Counter" "4"
"1" "Created" "DateTime" "9/9/2003 10:34:55 AM"
"2" "Author" "String" "Administrator"
"3" "Modified" "DateTime" "9/9/2003 10:34:55 AM"]]>
</ns0:ListItem>

Or conversely, given the above machine-generated XML, is it a valid XOML file (that can be loaded with the default WF loader)

What happens to the embedded element text (i.e. the CDATA) Will it validate   How is the text accessed inside this ListIem by the activity

Thanks,
Michael.

 




Re: Windows Workflow Foundation Multi-valued activity parameters?

Deling Ren - MSFT

I don't think I understood the question. What did you mean exactly by "multi-valued" activity parameter Would you please clarify it a little more Thanks.




Re: Windows Workflow Foundation Multi-valued activity parameters?

Michael Herman - Parallelspace

A DependencyProperty that can store a list or collection of values ...where the number of values will vary from one invocation to the next.




Re: Windows Workflow Foundation Multi-valued activity parameters?

Deling Ren - MSFT

I see. The activity containing the collection is serialized in this way: it serializes the public properties of every member of the collection. Here is an example. The custom activity is "MyActivity", it contains a dependency property of type "MyClass[]", MyClass type has one public property "string Name". Here is the xoml file for a workflow containing a MyActivity:

<SequentialWorkflowActivity x:Class="ArrayMemberBinding.Workflow2" x:Name="Workflow2" xmlns:ns0="clr-namespace:ArrayMemberBinding" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">

<ns0:MyActivity x:Name="myActivity1">

<ns0:MyActivity.MyClassInstance>

<x:Array Type="{x:Type ns0:MyClass}">

<ns0:MyClass MyName="Hello" />

<ns0:MyClass MyName="World" />

</x:Array>

</ns0:MyActivity.MyClassInstance>

</ns0:MyActivity>

</SequentialWorkflowActivity>






Re: Windows Workflow Foundation Multi-valued activity parameters?

Michael Herman - Parallelspace

...and this will work with any serializable type e.g. List<MyAddressInfoClass>

Are there any restrictions






Re: Windows Workflow Foundation Multi-valued activity parameters?

Roman Kiss

Michael,

another way is using the WorkflowParameterBindingCollection class.

Have a look at the following thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1009208&SiteID=1

or this thread, where a collection is the Hashtable

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1197644&SiteID=1

Thanks

Roman






Re: Windows Workflow Foundation Multi-valued activity parameters?

Michael Herman - Parallelspace

There's a hashtable sample in the SPD/WSS WorkflowActions:

<Action Name="Update List Item"
ClassName="Microsoft.SharePoint.WorkflowActions.UpdateItemActivity"
Assembly="Microsoft.SharePoint.WorkflowActions, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
AppliesTo="all"
Category="List Actions">
<RuleDesigner Sentence="Update item in %1">
<FieldBind Field="ListId,ListItem,ItemProperties" Text="this list" Id="1" DesignerType="UpdateListItem" />
</RuleDesigner>
<Parameters>
<Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext" Direction="In" />
<Parameter Name="ListId" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="ListItem" Type="System.Int32, mscorlib" Direction="In" />
<Parameter Name="ItemProperties" Type="System.Collections.Hashtable, mscorlib" Direction="In" />
</Parameters>
</Action>

Unfortunately, there's very little to reflect on:

public static DependencyProperty ItemPropertiesProperty = DependencyProperty.Register("ItemProperties", typeof(Hashtable), typeof(UpdateItemActivity));

public static DependencyProperty ListIdProperty = DependencyProperty.Register("ListId", typeof(string), typeof(UpdateItemActivity));

public static DependencyProperty ListItemProperty = DependencyProperty.Register("ListItem", typeof(int), typeof(UpdateItemActivity));

protected override ActivityExecutionStatus Execute(ActivityExecutionContext provider)

{

// This item is obfuscated and can not be translated.

}






Re: Windows Workflow Foundation Multi-valued activity parameters?

Michael Herman - Parallelspace

Hashtable, Dictionary<string> and Collection<string, string> all persist properly when used as DependencyProperty properites (see below) -- unfortunately, they all have problems when used in the WF designer property browser.

- <SequentialWorkflowActivity x:Class="foo.Workflow1" x:Name="Workflow1" xmlns:ns0="clr-namespaceStick out tonguearallelspace.WorkSmith.Activities;Assembly=PSNWorkSmithActivities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
- <ns0:Activity1 x:Name="CustomA" AString="CustomAAA">
- <ns0:Activity1.AHashtable>
- <ns1:Hashtable xmlns:ns1="clr-namespaceTongue Tiedystem.Collections;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xdef
- <x:Key>
<ns2Tongue Tiedtring>X456</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xabc
- <x:Key>
<ns2Tongue Tiedtring>X123</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
</ns1:Hashtable>
</ns0:Activity1.AHashtable>
- <ns0:Activity1.ADict>
- <ns3Big Smileictionary_x0060_2 xmlns:ns3="clr-namespaceTongue Tiedystem.Collections.Generic;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xabc
- <x:Key>
<ns2Tongue Tiedtring>X123</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xdef
- <x:Key>
<ns2Tongue Tiedtring>X456</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
</ns3Big Smileictionary_x0060_2>
</ns0:Activity1.ADict>
- <ns0:Activity1.ACollection>
- <ns4:Collection_x0060_1 xmlns:ns4="clr-namespaceTongue Tiedystem.Collections.ObjectModel;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">W123</ns2Tongue Tiedtring>
<ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">W456</ns2Tongue Tiedtring>
</ns4:Collection_x0060_1>
</ns0:Activity1.ACollection>
</ns0:Activity1>
- <ns0:Activity1 x:Name="CustomB" AString="CustomBBB" ACollection="{ActivityBind CustomA,Path=ACollection}">
- <ns0:Activity1.AHashtable>
- <ns1:Hashtable xmlns:ns1="clr-namespaceTongue Tiedystem.Collections;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xdef
- <x:Key>
<ns2Tongue Tiedtring>X456</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xabc
- <x:Key>
<ns2Tongue Tiedtring>X123</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
</ns1:Hashtable>
</ns0:Activity1.AHashtable>
- <ns0:Activity1.ADict>
- <ns3Big Smileictionary_x0060_2 xmlns:ns3="clr-namespaceTongue Tiedystem.Collections.Generic;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xabc
- <x:Key>
<ns2Tongue Tiedtring>X123</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
- <ns2Tongue Tiedtring xmlns:ns2="clr-namespaceTongue Tiedystem;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Xdef
- <x:Key>
<ns2Tongue Tiedtring>X456</ns2Tongue Tiedtring>
</x:Key>
</ns2Tongue Tiedtring>
</ns3Big Smileictionary_x0060_2>
</ns0:Activity1.ADict>
</ns0:Activity1>
</SequentialWorkflowActivity>





Re: Windows Workflow Foundation Multi-valued activity parameters?

Tom Lake - MSFT

The problems you are having with Hashtable, Dictionary<string> and Collection<string, string> properties in the property browser is not specific to WF, it is with VS in general. You will have the same problem with a custom user control. The solution is to use a custom UITypeEditor, go to http://msdn2.microsoft.com/en-us/library/53c49eck.aspx for a good starting point.






Re: Windows Workflow Foundation Multi-valued activity parameters?

Michael Herman - Parallelspace

Are there any built-in UITypeEditors for editing any type of "collection" that can be used (instead of writing one from scratch)

Which MSDN forums are the best for discussing these VS UITypeEditor-specific topics