Exemplo n.º 1
0
        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));
                    }
                }
            }
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
 public SqlNameValueCollection AddRange(SqlNameValueCollection coll)
 {
     if (!coll.IsNull)
     {
         _coll.Add(coll._coll);
     }
     return(this);
 }
Exemplo n.º 4
0
        public static SqlNameValueCollection NameValueCollClear(SqlNameValueCollection coll)
        {
            if (coll == null)
            {
                throw new ArgumentNullException("coll");
            }

            if (!coll.IsNull)
            {
                coll.Value.Clear();
            }
            return(coll);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public static SqlInt32 NameValueCollCount(SqlNameValueCollection coll)
        {
            if (coll == null)
            {
                throw new ArgumentNullException("coll");
            }

            if (coll.IsNull)
            {
                return(SqlInt32.Null);
            }

            return(coll.Value.Count);
        }
Exemplo n.º 8
0
        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));
            }
        }
Exemplo n.º 9
0
        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);
        }