public NamedValues AddValue(string key, object value) { var val = new ValueItem(key, value); _values.Add(val); return(this); }
public PositionedValues AddValue(object value) { var val = new ValueItem(value); _values.Add(val); return(this); }
public Set SetValue(string key, object value) { try { if (value != null) { if (IsHashSet(value)) { var gen = value.GetType().GenericTypeArguments[0]; var z = typeof(List <>).MakeGenericType(gen); var l = (IList)Activator.CreateInstance(z); var col = value as IEnumerable; if (col != null) { foreach (var o in col) { l.Add(o); } } value = l; } } var exists = _values.FirstOrDefault(v => v._key.Equals(key, StringComparison.OrdinalIgnoreCase)); if (exists == null) { var val = new ValueItem(key, value); _values.Add(val); } else { exists._value = value; } return(this); } catch (Exception e) { Console.WriteLine(e); throw; } }