locked
Enums RRS feed

  • Question

  • Hello, I am new to windows workflow, and I was trying to create a varialble of type enum.  I am using the designer to do so, but I am not sure how to format the VB expression for this type of variable.  Could someone tell me how this is done, or even if it can be done?

    Sunday, July 31, 2011 11:01 PM

Answers

  • I'd declare an enum type firstly, set the variable type to the declared type, then it will be easy to initialize in expression Textbox.

    For example:

    namespace EnumDesigner
    {
       public enum weekly { Mon = 1, Tus, Thu, Wen, Fri, Sat, Sun };
    }

        <Sequence.Variables>
          <Variable x:TypeArguments="local:weekly" Default="[weekly.Mon]" Name="Test" />
        </Sequence.Variables>

    • Marked as answer by LeoTang Tuesday, August 9, 2011 3:19 AM
    Friday, August 5, 2011 3:27 AM

All replies

  • Hi Aravan,

    I'm not sure that I follow you. Do you declare a variable of an enum type? Are you trying to use it inside an ExpressionTextBox? How do you want to use the variable?

    Thanks,

    Tony

    Tuesday, August 2, 2011 9:12 AM
  • Yes, that is what I did, I declared the variable of type system.enum and was trying to initialize it in the Expression Textbox.  Not sure if this is possible, or if my vb expression was wrong.
    Wednesday, August 3, 2011 8:49 PM
  • I'd declare an enum type firstly, set the variable type to the declared type, then it will be easy to initialize in expression Textbox.

    For example:

    namespace EnumDesigner
    {
       public enum weekly { Mon = 1, Tus, Thu, Wen, Fri, Sat, Sun };
    }

        <Sequence.Variables>
          <Variable x:TypeArguments="local:weekly" Default="[weekly.Mon]" Name="Test" />
        </Sequence.Variables>

    • Marked as answer by LeoTang Tuesday, August 9, 2011 3:19 AM
    Friday, August 5, 2011 3:27 AM
  • Here's an example. Suppose you have an enum like this, and you've declared a variable v of type MyEnum

        public enum MyEnum { A, B, C };

    you can drag an Assign activity and put 'v' (without the quotes) on the left hand side and 'MyEnum.B' on the right side. The output xaml would look like:

    <Assign>
      <Assign.To>
        <OutArgument x:TypeArguments="local:MyEnum">[v]</OutArgument>
      </Assign.To>
      <Assign.Value>
        <InArgument x:TypeArguments="local:MyEnum">[MyEnum.B]</InArgument>
      </Assign.Value>
    </Assign>

    Thanks,

    Tony

     

    Monday, August 8, 2011 1:41 AM