none
How to intialize\assign values into a variable of type HashTable or InArgument<Hashtable> in XAML?

    Question

  • I have developed a custom activity having an InArgument<Hashtable> of type Hashtable. i am using this custom activity in my client sequence activity which is a XAML based only. i want to assign\fill this Inargument with new hashtable, can any one suggest what would be the XAML syntext for the same??

    Saturday, June 27, 2009 10:34 AM

Answers

  • Hay Martin,

    Thanks a lot. Hureeeee, Its work for me. Yeh i agree with you to use XAMLService.Save to find out XAML, but the problem was i m not able to intialze variable of type HashTable as i do not know sysntax for intializing Default value of Such Variable thorugh code also!!!.

    I got the above code except the part why we have to use p:Literal class?  

    Also i have one more question that whenever i create any member of Type Variable\Argument, designer shows a look of Expression where i can add the value. I would like to know what class is this and if possible any link related to "How to use Expression\How To define Expression".

      
    Wednesday, July 08, 2009 12:19 PM

All replies

  • Hello Guys,

    Thanks for all visiting this question, however i badlly need it to be resoloved as i m like stuck up on this... I wish somebody can reply and hope that i correctlly framed the question...

    Waiting for the reply..!!((::
    Wednesday, July 01, 2009 9:19 AM
  • I don't know off the top of my head, but if you create a hash table in code and then use XamlServices.Save, you should be able to see what the xaml form would look like. 

    matt
    Program Manager -- Modeling Platform and Tools http://blogs.msdn.com/mwinkle
    Wednesday, July 01, 2009 10:09 PM
  • Hay Matt,

    Thanks a lot for your reply..Yeh i agree if we do so we are able to generate XAML which more or less similar to the one we are using in .net 3.5 WPF for assigning hashtable through XAML but that could not solve what i want to achieve.

    My problem is something different. i have a Variable<Hashtable>  of type hashtable and want to fill it. so my XAML code\WF\Activity look like below.

    If u check in that i have a variable of type hashtable and the only place i can intialize hashtable is it's Default field\value(Same as i do for another "string" type of variable). 

    the only thing i dont know is how to write Expression for assigning Hashtable into a Default value of  a variable.  


    <p:Activity >

        mc:Ignorable="" x:Class="DemoWorkflowClient.Sequence1"   
        xmlns
    ="http://schemas.microsoft.com/netfx/2009/xaml/activities/design"

        xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> 


        <p:Sequence DisplayName="Sequence1"> 
        
          <
    p:Sequence.Variables>
        
               <p:Variable x:TypeArguments="string" Default="[&quot;Hi&quot;]" Name="stringTypeVariable" />

               <p:Variable x:TypeArguments="Hashtable" Default="[]" Name="HashtableTypeVariable" />

     

     

     

    Thursday, July 02, 2009 6:17 AM
  • <p:Activity mc:Ignorable="" x:Class="WorkflowConsoleApplication1.Sequence1" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/design" xmlns:__Sequence1="clr-namespace:WorkflowConsoleApplication1;" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sc="clr-namespace:System.Collections;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <p:Sequence>
        <p:Sequence.Variables>
          <p:Variable x:TypeArguments="sc:Hashtable" Default="[New System.Collections.Hashtable]" Name="Hashtable" />
        </p:Sequence.Variables>
        <p:WriteLine>[Hashtable.Count.ToString]</p:WriteLine>
      </p:Sequence>
    </p:Activity>

    Friday, July 03, 2009 5:44 PM
  • Hay Martin,

    I agree. This is the way we can intialize hashTable type variable. here as we create a new object of hashtable in Default, it creates empty hashtable. What i would like to do is assign\Add few default values into hash table while intializaing.

    I was able to reached upto this point but could not fill the hashtable which is my final requirment.

    It whould be great if you modify above code a bit and fill two default values into hash table as define below.

     key    = "key1"
     Value = "MyFirstString"

     key    = "key2"
     Value = "MySecondString" 
    Monday, July 06, 2009 9:32 AM
  • Matt's suggestion to create the variable (and the sequence) in code and then use XamlServices.Save is a good one. See here:
          <p:Variable x:TypeArguments="sc:Hashtable" Name="myHashTable">
            <p:Variable.Default>
              <p:Literal x:TypeArguments="sc:Hashtable">
                <sc:Hashtable>
                  <x:String>
                    MyFirstString<x:Key>
                      <x:String>key1</x:String>
                    </x:Key>
                  </x:String>
                  <x:String>
                    MySecondString<x:Key>
                      <x:String>key2</x:String>
                    </x:Key>
                  </x:String>
                </sc:Hashtable>
              </p:Literal>
            </p:Variable.Default>
          </p:Variable>
    
    Tuesday, July 07, 2009 4:48 PM
  • Hay Martin,

    Thanks a lot. Hureeeee, Its work for me. Yeh i agree with you to use XAMLService.Save to find out XAML, but the problem was i m not able to intialze variable of type HashTable as i do not know sysntax for intializing Default value of Such Variable thorugh code also!!!.

    I got the above code except the part why we have to use p:Literal class?  

    Also i have one more question that whenever i create any member of Type Variable\Argument, designer shows a look of Expression where i can add the value. I would like to know what class is this and if possible any link related to "How to use Expression\How To define Expression".

      
    Wednesday, July 08, 2009 12:19 PM