/// <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); }
protected override Node CloneCore() { var n = new Wikitext(); n.Lines.Add(Lines); return(n); }
public ArgumentReference(Wikitext name, Wikitext defaultValue) { Name = name; DefaultValue = defaultValue; }
public ArgumentReference(Wikitext name) : this(name, null) { }
public TemplateArgument(Wikitext name, Wikitext value) { Name = name; Value = value; }
public WikiImageLinkArgument(Wikitext name, Wikitext value) { Name = name; Value = value; }