/// <summary> /// Add the contents of an array to a LazyList /// </summary> /// <param name="list">The list to add to or null if none yet created.</param> /// <param name="array">The Array whose contents should be added.</param> /// <returns>The lazylist created or added to.</returns> public static object AddArray(object list, Array array) { for (int i = 0; array != null && i < array.Length; i++) { list = LazyList.Add(list, array.GetValue(i)); } return(list); }
/// <summary> /// Add the contents of a Collection to a LazyList /// </summary> /// <typeparam name="E">Generics of The List to be created</typeparam> /// <param name="list">The list to add to or null if none yet created.</param> /// <param name="collection">The Collection whose contents should be added.</param> /// <returns>The lazylist created or added to.</returns> public static object AddCollection <E>(object list, ICollection <E> collection) { foreach (E item in collection) { list = LazyList.Add(list, item); } return(list); }
/// <summary> /// Put multi valued entry. /// Existing values will be relaced with the new value /// </summary> /// <param name="name"></param> /// <param name="values"></param> public void AddValues(K name, string[] values) { object list = null; for (int i = 0; i < values.Length; i++) { list = LazyList.Add(list, values[i]); } Add(name, list); }
/// <summary> /// Add and Exception to the List of Multiple Exceptions /// </summary> /// <param name="e"></param> public void Add(Exception e) { if (e is MultiException) { MultiException me = (MultiException)e; for (int i = 0; i < LazyList.Size(me.nested); i++) { nested = LazyList.Add(nested, LazyList.Get(me.nested, i)); } } else { nested = LazyList.Add(nested, e); } }
/// <summary> /// Add value to multi valued entry. /// If the entry is single valued, it is converted to the first /// value of a multi valued entry. /// The value will be (existing value[s] + the new value[s]) /// </summary> /// <param name="name">The entry key.</param> /// <param name="value">The entry value.</param> public void Append(K name, object value) { object lo = _map.ContainsKey(name) ? _map[name] : null; object ln = LazyList.Add(lo, value); if (lo != ln) { if (_map.ContainsKey(name)) { _map[name] = ln; } else { _map.Add(name, ln); } } }
/// <summary> /// Put and entry into the map. /// Existing values will be relaced with the new value /// </summary> /// <param name="name">The entry key.</param> /// <param name="value">The entry value.</param> public new void Add(K name, object value) { _map.Add(name, LazyList.Add(null, value)); }