コード例 #1
0
                internal static void SetValue(UrlQueryParameter qp, string value)
                {
                    Collection changedColl = qp.GetSync(() =>
                    {
                        if (qp._set == null)
                        {
                            qp._value = value;
                            return(null);
                        }
                        return(qp._set.GetSync(() =>
                        {
                            if ((qp._value == null) ? value == null : value != null && value == qp._value)
                            {
                                return null;
                            }
                            qp._value = value;
                            return qp._set._collection;
                        }));
                    });

                    if (changedColl != null)
                    {
                        changedColl.OnChange();
                    }
                }
コード例 #2
0
            public IEnumerable <string> GetAllValues(string key)
            {
                ValueSet vs = ValueSet.Get(this, key);

                if (vs != null)
                {
                    for (UrlQueryParameter p = vs.First; p != null; p = p._nextValue)
                    {
                        if (p.GetSync(() => p._set == null || !ReferenceEquals(p._set, vs)))
                        {
                            throw new InvalidOperationException("Collection changed");
                        }
                        yield return(p.ToString());
                    }
                }
            }
コード例 #3
0
                internal static void SetKey(UrlQueryParameter qp, string key)
                {
                    Collection changedColl = qp.GetSync(() =>
                    {
                        if (qp._set == null)
                        {
                            qp._key = key;
                            return(null);
                        }
                        return(qp._set.GetSync(() =>
                        {
                            if (qp.Key == key)
                            {
                                return null;
                            }
                            if (qp._set._collection == null)
                            {
                                // TODO: Not in collection
                                return null;
                            }
                            return qp._set._collection.GetSync((Collection c) =>
                            {
                                if (c._keyComparer.Equals(key, qp.Key))
                                {
                                    // TODO: Modify key
                                }
                                else
                                {
                                    // TODO: Ttoal key change
                                }
                                return c;
                            }, qp._set._collection);
                        }));
                    });

                    if (changedColl != null)
                    {
                        changedColl.OnChange();
                    }
                }
コード例 #4
0
                internal static bool Remove(UrlQueryParameter qp)
                {
                    if (qp == null)
                    {
                        return(false);
                    }
                    Collection changedCol = qp.GetSync(() =>
                    {
                        if (qp._set == null)
                        {
                            return(null);
                        }
                        return(qp._set.GetSync((ValueSet vs) =>
                        {
                            if (vs._collection == null)
                            {
                                if (qp._previousValue == null)
                                {
                                    if ((vs._firstParameter = qp._nextValue) == null)
                                    {
                                        vs._lastParameter = null;
                                    }
                                    else
                                    {
                                        qp._nextValue = qp._nextValue._previousValue = null;
                                    }
                                }
                                else
                                {
                                    if ((qp._previousValue._nextValue = qp._nextValue) == null)
                                    {
                                        vs._lastParameter = qp._previousValue;
                                    }
                                    else
                                    {
                                        qp._nextValue._previousValue = qp._previousValue;
                                        qp._nextValue = null;
                                    }
                                    qp._previousValue = null;
                                }
                                qp._set = null;
                                return null;
                            }
                            vs._collection.GetSync((Collection c) =>
                            {
                                if (qp._previousParameter == null)
                                {
                                    if ((c._firstParameter = qp._nextParameter) == null)
                                    {
                                        c._lastParameter = vs._firstParameter = vs._lastParameter = null;
                                        c._firstSet = c._lastSet = qp._set = vs._next = vs._previous = null;
                                        vs._collection = null;
                                        return c;
                                    }
                                    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 (qp._previousValue == null)
                                {
                                    if ((vs._firstParameter = qp._nextValue) == null)
                                    {
                                        vs._lastParameter = null;
                                        if (vs._previous == null)
                                        {
                                            (c._firstSet = vs._next)._previous = null;
                                            vs._next = 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;
                                        if (qp._key == null)
                                        {
                                            qp._key = vs._key;
                                        }
                                        qp._set = null;
                                    }
                                    else
                                    {
                                        qp._nextValue = qp._nextValue._previousValue = null;
                                    }
                                }
                                else
                                {
                                    if ((qp._previousValue._nextValue = qp._nextValue) == null)
                                    {
                                        vs._lastParameter = qp._previousValue;
                                    }
                                    else
                                    {
                                        qp._nextValue._previousValue = qp._previousValue;
                                        qp._nextValue = null;
                                    }
                                    qp._previousValue = null;
                                }
                                qp._set = null;
                                return c;
                            }, vs._collection);
                            return vs._collection;
                        }, qp._set));
                    });

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