Assigning dynamic value to the receive activity properties

508 Views Asked by At

I am writing a custom activity using imperative code. In my compsoition, I have Receive activity as a one of the composed activity. In that activity, I want to set ServiceContractName and OperationName property dynamically, meaning, when developer who is consuming my custom activity have to set. So I declared one property and one InArgument for this purpose. I assign this property and Argument value to the local (sequence varriable). When I try to assign these varriables to Receive activity properties, I am getting compile time error. How to assign a Varriable to string and XName properties of Receive activity.

return new Sequence
{
    Variables = { operationName, serviceContractName},
    Activities = 
    {
        new Assign<string>
        {
            To = new OutArgument<string>(serviceContractName),
            Value = new InArgument<string>(ctx => ServiceContractName.Get(ctx))
        },

        new Assign<string>
        {
            To = new OutArgument<string>(operationName),
            Value = new InArgument<string>(ctx => OperationName)
        },

        new Receive
            {
                ServiceContractName = serviceContractName,
                OperationName = operationName,
                CanCreateInstance = true,
                Content = new ReceiveMessageContent
                {
                    Message = new OutArgument<Request>(request)
                }
            }
        },
    }
};
1

There are 1 best solutions below

0
Maurice On BEST ANSWER

You can't do that. The ServiceContractName and the OperationName are not InArguments but normal properties and they have to be set at design time, not at run time.