/// <summary> /// Adds the specified name. /// </summary> /// <param name="name">The name.</param> /// <param name="type">The type.</param> /// <param name="value">The value.</param> /// <param name="checked">if set to <c>true</c> [checked].</param> /// <param name="text">The text.</param> public void Add(string name, string type, string value, bool @checked = false, string text = null) { // selectName if (type == "radio" || type.StartsWith("select")) { _selectName = name; } // process option if (type == "radio" || type == "option") { if (!Selects.TryGetValue(_selectName, out var select)) { Selects[_selectName] = select = new Dictionary <string, string>(); if (value == null) { @checked = true; } } select[value ?? text ?? string.Empty] = text; if (@checked) { if (!Types.ContainsKey(_selectName)) { Types.Add(_selectName, "radio"); } Values[_selectName] = value ?? text; } if (type == "option") { return; } } // skip if button else if (type == "button") { return; } // skip if name blank else if (name == null) { return; } // multi-key if (Values.ContainsKey(name)) { if (type == "radio") { return; } for (var i = 1; i < int.MaxValue; i++) { var newName = $"{name}>{i}"; if (!Values.ContainsKey(newName)) { name = newName; break; } } } // set-value SetValue(name, value, type, @checked); }