コード例 #1
0
        //  -------------------------------------------------------------------
        /// <summary>
        /// Creates a new tree node that wraps the specified target.
        /// </summary>
        /// <remarks>
        /// The new tree node automatically obtains its text representation
        /// from the name of the target, if it has one.
        /// </remarks>
        /// <param name="target">
        /// The target to be wrapped.
        /// </param>
        public TargetTreeNode(ITarget target)
        {
            this.target = target;

            INameableTarget nameable = target as INameableTarget;

            if (nameable != null)
            {
                this.Text = nameable.Name;
            }

            if (target.IsContainer)
            {
                PlaceholderTreeNode node = new PlaceholderTreeNode();
                this.Nodes.Add(node);
            }
        }
コード例 #2
0
        //  -------------------------------------------------------------------
        /// <summary>
        /// Resolves the specified parameter string by replacing any variable
        /// placeholders with their actual values. Currently the following
        /// placeholders are supported:
        ///
        /// * ${user} - the username
        /// * ${pw} - the password
        /// * ${assignment.name} - the name of the assignment
        ///
        /// </summary>
        /// <param name="value">
        /// The string containing placeholders to be resolved.
        /// </param>
        /// <returns>
        /// A copy of the original string with the placeholders replaced by
        /// their actual values.
        /// </returns>
        public string ResolveParameter(string value)
        {
            Regex regex;

            regex = new Regex("\\$\\{user\\}");
            value = regex.Replace(value, username);

            regex = new Regex("\\$\\{pw\\}");
            value = regex.Replace(value, password);

            if (assignment is INameableTarget)
            {
                INameableTarget nameable = (INameableTarget)assignment;

                if (nameable != null)
                {
                    regex = new Regex("\\$\\{assignment\\.name\\}");
                    string asmtName = nameable.Name.Replace(" ", "%20");
                    value = regex.Replace(value, asmtName);
                }
            }

            return(value);
        }