public string this[string key]
 {
     get
     {
         return(GetSync(() =>
         {
             ValueSet vs = ValueSet.Get(this, key);
             if (vs == null)
             {
                 throw new KeyNotFoundException();
             }
             return vs.GetSync(() =>
             {
                 if (vs.Key != key)
                 {
                     for (UrlQueryParameter p = vs.First._nextValue; p != null; p = p._nextValue)
                     {
                         if (p._key != null && p._key == key)
                         {
                             return p.Value;
                         }
                     }
                 }
                 return vs.First.Value;
             });
         }));
     }
     set { ValueSet.Set(this, key, value); }
 }
 public bool HasMultipleValues(string key)
 {
     return(GetSync(() =>
     {
         ValueSet vs = ValueSet.Get(this, key);
         return vs != null && vs.GetSync(() => vs.First._nextValue != null);
     }));
 }
                internal static bool Remove(ValueSet vs)
                {
                    if (vs == null)
                    {
                        return(false);
                    }
                    Collection changedColl = vs.GetSync(() =>
                    {
                        if (vs._collection == null)
                        {
                            return(null);
                        }

                        return(vs._collection.GetSync((Collection c) =>
                        {
                            for (UrlQueryParameter qp = vs._firstParameter; qp != null; qp = vs._firstParameter)
                            {
                                qp.InvokeSync(() =>
                                {
                                    if (qp._previousValue != null || qp._set == null || !ReferenceEquals(qp._set, vs))
                                    {
                                        throw new InvalidOperationException("Collection was modified");
                                    }
                                    if ((vs._firstParameter = qp._nextValue) != null)
                                    {
                                        qp._nextValue = qp._nextValue._previousValue = null;
                                    }
                                    if (qp._key == null)
                                    {
                                        qp._key = vs._key;
                                    }
                                    qp._set = null;
                                    if (qp._previousParameter == null)
                                    {
                                        if ((c._firstParameter = qp._nextParameter) == null)
                                        {
                                            c._lastParameter = null;
                                        }
                                        else
                                        {
                                            qp._nextParameter = qp._nextParameter._previousParameter = null;
                                        }
                                    }
                                    else
                                    {
                                        if ((qp._previousParameter._nextParameter = qp._nextParameter) == null)
                                        {
                                            c._lastParameter = qp._previousParameter;
                                        }
                                        else
                                        {
                                            qp._nextParameter._previousParameter = qp._previousParameter;
                                            qp._nextParameter = null;
                                        }
                                        qp._previousParameter = null;
                                    }
                                });
                            }
                            if (vs._previous == null)
                            {
                                if ((c._firstSet = vs._next) == null)
                                {
                                    c._lastSet = null;
                                }
                                else
                                {
                                    vs._next = vs._next._previous = null;
                                }
                            }
                            else
                            {
                                if ((vs._previous._next = vs._next) == null)
                                {
                                    c._lastSet = vs._previous;
                                }
                                else
                                {
                                    vs._next._previous = vs._previous;
                                    vs._next = null;
                                }
                                vs._previous = null;
                            }
                            vs._collection = null;
                            return c;
                        }, vs._collection));
                    });

                    if (changedColl == null)
                    {
                        return(false);
                    }
                    changedColl.OnChange();
                    return(true);
                }