locked
Adding variable's default value in workflow programatically RRS feed

  • Question

  • I am trying to create a workflow like this using C# code

    <Activity mc:Ignorable="sap" x:Class="Activity1" this:Activity1.var1="100" this:Activity1.var2="200" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:mwc="clr-namespace:MeghaVault.WorkflowActivityEngine.CustomActivity;assembly=MeghaVault.WorkflowActivityEngine.CustomActivity" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:this="clr-namespace:" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <x:Members>
        <x:Property Name="var1" Type="InArgument(x:Int32)" />
        <x:Property Name="var2" Type="InArgument(x:Int32)" />
        <x:Property Name="ovar1" Type="OutArgument(x:Int32)" />
        <x:Property Name="ovar2" Type="OutArgument(x:String)" />
      </x:Members>
    </Activity>
    

    I am able to create everything except assigining default values to variables "var1" and "var2". I am using ActivityBuilder class to create a workflow but don't know how to assign those default values to variables.

    Please advice.


    Software Engineer
    Saturday, September 3, 2011 7:59 PM

Answers

  • The DynamicActivityProperty class includes a property for Value, which you can set when you add the property to the collection.  

    MyActivityBuilder.Properties.Add (new DynamicActivityProperty
        {
            Name = "var1",
            Type =  typeof(InArgument<int>),
            Value = defaultvalue
        });
    



    Tom Overton
    Sunday, September 4, 2011 7:43 AM

All replies

  • The DynamicActivityProperty class includes a property for Value, which you can set when you add the property to the collection.  

    MyActivityBuilder.Properties.Add (new DynamicActivityProperty
        {
            Name = "var1",
            Type =  typeof(InArgument<int>),
            Value = defaultvalue
        });
    



    Tom Overton
    Sunday, September 4, 2011 7:43 AM
  • Thanks Tom,

    It worked.

    regards,

     


    Software Engineer
    Monday, September 5, 2011 9:14 PM