Example #1
0
        /// <summary>
        /// Appends to the previous contents the new text and arguments given.
        /// </summary>
        /// <param name="text">The text to append to this command. Embedded arguments are specified
        /// using the standard '{n}' positional format.</param>
        /// <param name="args">An optional collection containing the arguments specified in the
        /// text to append to this command.</param>
        /// <returns>A self-reference to permit a fluent syntax chaining.</returns>
        public IRawCommand Append(string text, params object[] args)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.ToString());
            }
            if (text == null)
            {
                throw new ArgumentNullException("spec", "Text cannot be null.");
            }

            if (args != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    IParameter par = Parameters.AddCreate(args[i] is IParameter
                                                ? ((IParameter)args[i]).Value
                                                : args[i]);

                    var old = "{{{0}}}".FormatWith(i);
                    text = text.Replace(old, par.Name);
                }
            }

            TheTextData = TheTextData == null ? text : string.Format("{0}{1}", TheTextData, text);
            return(this);
        }