public static IEnumerable NameValueCollEnumerate(SqlNameValueCollection coll) { if (coll == null) { throw new ArgumentNullException("coll"); } if (coll.IsNull) { yield break; } foreach (String name in coll.Value) { var values = coll.Value.GetValues(name); if (values == null) { yield return(new Tuple <String, String>(name, default(String))); } else { foreach (String value in values) { yield return(new Tuple <String, String>(name, value)); } } } }
public static SqlString NameValueCollFormat(SqlNameValueCollection coll, SqlString keyDelimiter, SqlString itemDelimiter) { if (coll == null) { throw new ArgumentNullException("coll"); } if (coll.IsNull || keyDelimiter.IsNull || itemDelimiter.IsNull) { return(SqlFormatting.NullText); } var sb = new StringBuilder(); coll.Value.OfType <String>().ForEach((t, i) => { if (i > 0) { sb.Append(itemDelimiter.Value); } sb.Append(t); sb.Append(keyDelimiter.Value); sb.Append(coll.Value[t]); }); return(sb.ToString()); }
public SqlNameValueCollection AddRange(SqlNameValueCollection coll) { if (!coll.IsNull) { _coll.Add(coll._coll); } return(this); }
public static SqlNameValueCollection NameValueCollClear(SqlNameValueCollection coll) { if (coll == null) { throw new ArgumentNullException("coll"); } if (!coll.IsNull) { coll.Value.Clear(); } return(coll); }
public static SqlNameValueCollection NameValueCollRemove(SqlNameValueCollection coll, [SqlFacet(MaxSize = -1)] SqlString name) { if (coll == null) { throw new ArgumentNullException("coll"); } if (!coll.IsNull) { coll.Value.Remove(name.IsNull ? default(String) : name.Value); } return(coll); }
public static SqlString NameValueCollGet(SqlNameValueCollection coll, [SqlFacet(MaxSize = -1)] SqlString name) { if (coll == null) { throw new ArgumentNullException("coll"); } if (coll.IsNull) { return(SqlString.Null); } return(coll.Value[name.IsNull ? default(String) : name.Value] ?? SqlString.Null); }
public static SqlInt32 NameValueCollCount(SqlNameValueCollection coll) { if (coll == null) { throw new ArgumentNullException("coll"); } if (coll.IsNull) { return(SqlInt32.Null); } return(coll.Value.Count); }
public static IEnumerable NameValueCollGetValues(SqlNameValueCollection coll, [SqlFacet(MaxSize = -1)] SqlString name) { if (coll == null) { throw new ArgumentNullException("coll"); } if (coll.IsNull) { yield break; } foreach (String value in coll.Value.GetValues(name.IsNull ? default(String) : name.Value)) { yield return(new Tuple <String, String>(name.IsNull ? default(String) : name.Value, value)); } }
public static SqlNameValueCollection NameValueCollAddRange(SqlNameValueCollection coll, SqlNameValueCollection range) { if (coll == null) { throw new ArgumentNullException("coll"); } if (range == null) { throw new ArgumentNullException("range"); } if (!coll.IsNull && !range.IsNull) { coll.Value.Add(range.Value); } return(coll); }