예제 #1
0
        /// <summary>
        /// Sets the value of the specified template argument. If the argument doesn't exist,
        /// this function will create a new one and returns it.
        /// </summary>
        /// <param name="argumentName">The name of the argument to set.</param>
        /// <param name="argumentValue">The new value of the argument. If the value is empty, it should be an empty <see cref="Wikitext"/> instance.</param>
        /// <returns>The <see cref="TemplateArgument"/> whose value has been set/created.</returns>
        /// <remarks>If there are multiple arguments sharing the same name, the value of the effective one (often the last one) will be set and returned.</remarks>
        /// <exception cref="ArgumentNullException">Either <paramref name="argumentName"/> or <paramref name="argumentValue"/> is <c>null</c>.</exception>
        public TemplateArgument SetValue(Wikitext argumentName, Wikitext argumentValue)
        {
            if (argumentName == null)
            {
                throw new ArgumentNullException(nameof(argumentName));
            }
            if (argumentValue == null)
            {
                throw new ArgumentNullException(nameof(argumentValue));
            }
            var arg = this[argumentName.ToString()];

            if (arg == null)
            {
                // TODO automatically convert named argument to positional one
                // E.g. {{T|1=abc}} --> {{T|abc}}
                arg = new TemplateArgument(argumentName, argumentValue);
                Add(arg);
            }
            else
            {
                arg.Value = argumentValue;
            }
            return(arg);
        }
예제 #2
0
        protected override Node CloneCore()
        {
            var n = new Wikitext();

            n.Lines.Add(Lines);
            return(n);
        }
예제 #3
0
 public ArgumentReference(Wikitext name, Wikitext defaultValue)
 {
     Name         = name;
     DefaultValue = defaultValue;
 }
예제 #4
0
 public ArgumentReference(Wikitext name) : this(name, null)
 {
 }
예제 #5
0
 public TemplateArgument(Wikitext name, Wikitext value)
 {
     Name  = name;
     Value = value;
 }
예제 #6
0
 public WikiImageLinkArgument(Wikitext name, Wikitext value)
 {
     Name  = name;
     Value = value;
 }