Example #1
0
        /// <summary>
        /// Initialises the DynamicArgumentDialog instance with child workflow arguments by loading the specified child workflow then deriving its arguments.
        /// </summary>
        private void InitImportDynamicArgumentDialog()
        {
            workflowPath = this.ModelItem.Properties["WorkflowPath"].Value.GetCurrentValue() as string;
            if (!workflowPath.Contains(":"))
            {
                workflowPath = SelectHelper.ProjectLocation + Path.DirectorySeparatorChar + workflowPath;
            }

            if ((!string.IsNullOrEmpty(workflowPath)) && workflowPath.Trim().Length > 0)
            {
                argumentDictionary = new Dictionary <string, Argument>();

                //this.currentlyLoadedWorkflowPath = workflowPath;

                try
                {
                    DynamicActivity dynamicActivity = DynamicActivityStore.GetActivity(workflowPath, 1); //Designer mode
                    if (dynamicActivity != null)
                    {
                        foreach (DynamicActivityProperty property in dynamicActivity.Properties)
                        {
                            Argument newArgument = null;
                            if (property.Type.GetGenericTypeDefinition().BaseType == typeof(InArgument))
                            {
                                newArgument = Argument.Create(property.Type.GetGenericArguments()[0], ArgumentDirection.In);
                            }

                            if (property.Type.GetGenericTypeDefinition().BaseType == typeof(OutArgument))
                            {
                                newArgument = Argument.Create(property.Type.GetGenericArguments()[0], ArgumentDirection.Out);
                            }

                            if (property.Type.GetGenericTypeDefinition().BaseType == typeof(InOutArgument))
                            {
                                newArgument = Argument.Create(property.Type.GetGenericArguments()[0], ArgumentDirection.InOut);
                            }

                            if (newArgument != null)
                            {
                                argumentDictionary.Add(property.Name, newArgument);
                            }
                        }
                    }
                }
                catch
                {
                    // ignore load failures - leave to handle in CacheMetadata
                }
            }
        }
Example #2
0
        /// <summary>
        /// Converts a string representing a file path to just the filename component of that string. Any environment variables within the string
        /// are first resolved.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// A converted string. If the method returns null, the valid null value is used.
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string fullPath = value as string;

            if (!string.IsNullOrEmpty(fullPath))
            {
                try
                {
                    return(Path.GetFileName(DynamicActivityStore.ReplaceEnvironmentVariables(fullPath)));
                }
                catch
                {
                    return(fullPath);
                }
            }

            return(Resources.UndefinedPathErrorText);
        }