예제 #1
0
        /// <summary>
        /// Generate a parameter name that is unique to the workflow. Use the argument name if possible, otherwise append a number.
        /// </summary>
        private static string GeneratetUniqueNameForExpressionParameter(Workflow wf, WfActivity activity, ActivityArgument argument)
        {
            if (argument.Name == null)
            {
                throw new ArgumentException("Argument missing name");
            }

            var composedName = activity.Is <Workflow>()
                                   ? argument.Name
                                   : string.Format("{0}_{1}", (activity.Name ?? string.Empty), argument.Name);


            if (!wf.ExpressionParameters.Any(expPar => expPar.Name == composedName))
            {
                return(composedName);
            }

            var    count = 0;
            string proposedName;

            do
            {
                count++;
                proposedName = String.Format("{0}{1}", composedName, count);
            }while (wf.ExpressionParameters.Any(expPar => expPar.Name == proposedName));

            return(proposedName);
        }
예제 #2
0
        public static void AddExpressionToMapArguments(Workflow wf, WfActivity fromActivity, WfActivity toActivity, string fromArgumentName, string toArgumentName)
        {
            ActivityArgument fromArgument;

            if (fromActivity.Is <Workflow>())
            {
                fromArgument = fromActivity.GetInputArgument(fromArgumentName);
            }
            else
            {
                fromArgument = fromActivity.GetOutputArgument(fromArgumentName);
            }

            if (fromArgument == null)
            {
                throw new ArgumentException(String.Format("Unable to find argument on the from Activity: [{0}].[{1}]", fromActivity.Name, fromArgumentName));
            }

            var subString = CreateArgumentInstance(wf, fromActivity, fromArgument);

            AddExpressionToActivityArgument(wf, toActivity, toArgumentName, String.Format("[{0}]", subString), false);
        }