windows Workflow foundation - passing custom variable between different activity in a workflow
<p>I am passing a custom variable type from one action to another action in a workflow.  Here is the definition of the custom object</p>

<pre><code>       public class ConfigDatabase
        {
            public string Name;
            public string Host;
            public string Port;
            public string Instance;
            public string User;
            public string Password;
        }

        public class ConfigDatabases
        {
            public string DatabaseToUse;
            public List&lt;ConfigDatabase&gt; DatabaseList;

            public ConfigDatabases()
            {
                DatabaseList = new List&lt;ConfigDatabase&gt;();
            }
        }

        public class ConfigEnvironment
        {
            public ConfigDatabases EnvironmentConfigDatabase;

            public ConfigEnvironment()
            {
                EnvironmentConfigDatabase = new ConfigDatabases();
            }

            public ConfigDatabase ReturnDatabaseInfo()
            {
                ConfigDatabase ConfigDatabaseInfo = new ConfigDatabase();
                for (int Count1 = 0; Count1 &lt; EnvironmentConfigDatabase.DatabaseList.Count; Count1++)
                {
                    if (EnvironmentConfigDatabase.DatabaseList[Count1].Name == EnvironmentConfigDatabase.DatabaseToUse)
                    {
                        ConfigDatabaseInfo = EnvironmentConfigDatabase.DatabaseList[Count1];
                        return ConfigDatabaseInfo;
                    }
                }
                return ConfigDatabaseInfo;
            }

            public string GetDatabaseConnectionString()
            {
                ConfigDatabase DatabaseInfo = ReturnDatabaseInfo();
                string ConnectionString = "Data Source=(description=(address=(protocol=tcp)(host=" + DatabaseInfo.Host + ")(port=" + DatabaseInfo.Port + "))(connect_data=(sid=" + DatabaseInfo.Instance + ")));User ID=" + DatabaseInfo.User + ";Password=" + DatabaseInfo.Password + ";";
                return ConnectionString;
            }
        }
</code></pre>

<p>During the first step of the action, it will run the following code to load the config data from a file and store in an object (ConfigEnvironment) that is returned in function Execute</p>

<pre><code>public sealed class InitializeEnvironment : CodeActivity&lt;ConfigEnvironment&gt;
{
    // Define an activity input argument of type string
    public InArgument&lt;string&gt; EnvironmentFileLocation { get; set; }

    // If your activity returns a value, derive from CodeActivity&lt;TResult&gt;
    // and return the value from the Execute method.
    protected override ConfigEnvironment Execute(CodeActivityContext context)
    {
        // Obtain the runtime value of the Text input argument
        string EnvironmentFile = context.GetValue(this.EnvironmentFileLocation);
        EnvironmentConfigInitialization EnvironmentInitialize = new EnvironmentConfigInitialization(EnvironmentFile);
        ConfigEnvironment EnvironmentDetail = EnvironmentInitialize.LoadData();
        return EnvironmentDetail;
    }
}
</code></pre>

<p>In the subsequent activity in the workflow, I would like to obtain the data stored in this object.  However, the following code will have a compile error as EnvironmentDetail object could not find the function GetDatabaseConnectionString.</p>

<pre><code>public sealed class ExecuteSQL : CodeActivity&lt;DataRowCollection&gt;
{
    // Define an activity input argument of type string
    public InArgument&lt;string&gt; SQLScript { get; set; }
    public InArgument&lt;ConfigEnvironment&gt; EnvironmentDetail { get; set; }

    // If your activity returns a value, derive from CodeActivity&lt;TResult&gt;
    // and return the value from the Execute method.
    protected override DataRowCollection Execute(CodeActivityContext context)
    {

        string connectionString4 = EnvironmentDetail.GetDatabaseConnectionString(); //This create a compile error

}
</code></pre>

<p>}</p>

<p>The compile warning is the following
'System.Activities.InArgument' does not contain a definition for 'GetDatabaseConnectionString' and no extension method 'GetDatabaseConnectionString' accepting a first argument of type 'System.Activities.InArgument' could be found (are you missing a using directive or an assembly reference?)</p>
