Esempio n. 1
0
            public void Process()
            {
                var    ps = _path.Split(PATH_SEPARATOR, StringSplitOptions.RemoveEmptyEntries);
                DTopic cur = _root, next;
                bool   noCreation = (_cmd == 12 && _p1 == null && _p2 == null) || (_cmd == 10 && _p1 != null && _p1.ValueType == JSC.JSValueType.String && _p2 != null && _p2.ValueType == JSC.JSValueType.String);

                for (int i = 0; i < ps.Length; i++)
                {
                    next = cur.GetChild(ps[i], !noCreation);
                    if (next == null) // Topic not exist
                    {
                        return;
                    }
                    cur = next;
                }
                if (noCreation)
                {
                    if (_cmd == 10) // move
                    {
                        DTopic parent = _root;
                        ps = (_p1.Value as string).Split(PATH_SEPARATOR, StringSplitOptions.RemoveEmptyEntries); //-V3095
                        for (int i = 0; i < ps.Length; i++)
                        {
                            next = parent.GetChild(ps[i], false);
                            if (next == null) // Topic not exist
                            {
                                return;
                            }
                            parent = next;
                        }
                        next            = new DTopic(parent, _p2.Value as string); //-V3095
                        next._children  = cur._children;
                        next._state     = cur._state;
                        next._manifest  = cur._manifest;
                        next._typeTopic = cur._typeTopic;

                        cur.parent.ChangedReise(Art.RemoveChild, cur);
                        cur.parent._children.Remove(cur);

                        parent.SetChild(next);
                        next.UpdatePath();
                        parent.ChangedReise(Art.addChild, next);
                    }
                    else if (_cmd == 12) // delete
                    {
                        cur._disposed = true;
                        var parent = cur.parent;
                        if (parent != null)
                        {
                            parent.RemoveChild(cur);
                            cur.ChangedReise(Art.RemoveChild, cur);
                            parent.ChangedReise(Art.RemoveChild, cur);
                        }
                    }
                }
                else
                {
                    if (_p1 != null)
                    {
                        cur.ValuePublished(_p1);
                    }
                    if (_p2 != null)
                    {
                        cur.ManifestPublished(_p2);
                    }
                }
            }
Esempio n. 2
0
            public void Process()
            {
                int idx1 = _cur.path.Length;

                if (idx1 > 1)
                {
                    idx1++;
                }
                if (_path == null || _path.Length <= _cur.path.Length)
                {
                    if (_cur._disposed)
                    {
                        _tcs.SetResult(null);
                        lock (_cur) {
                            _cur._req = null;
                            if (this._reqs != null)
                            {
                                foreach (var r in _reqs)
                                {
                                    App.PostMsg(r);
                                }
                            }
                        }
                    }
                    else if (_cur._state != null)
                    {
                        if (_cur._typeLoading)
                        {
                            _cur.changed += TypeLoaded;
                        }
                        else
                        {
                            _tcs.SetResult(_cur);
                        }
                        lock (_cur) {
                            _cur._req = null;
                            if (this._reqs != null)
                            {
                                foreach (var r in _reqs)
                                {
                                    App.PostMsg(r);
                                }
                            }
                        }
                    }
                    else
                    {
                        lock (_cur) {
                            if (_cur._req != null && _cur._req != this) //-V3054
                            {
                                if (_cur._req._reqs == null)
                                {
                                    _cur._req._reqs = new List <TopicReq>();
                                }
                                _cur._req._reqs.Add(this);
                                return;
                            }
                            else
                            {
                                _cur._req = this;
                            }
                        }
                        _cur.Connection.SendReq(4, this, _cur.path, 3);
                    }
                    return;
                }
                DTopic next = null;
                int    idx2 = _path.IndexOf('/', idx1);

                if (idx2 < 0)
                {
                    idx2 = _path.Length;
                }
                string name = _path.Substring(idx1, idx2 - idx1);

                if (_cur._children == null && _cur._state == null)
                {
                    lock (_cur) {
                        if (_cur._req != null && _cur._req != this) //-V3054
                        {
                            if (_cur._req._reqs == null)
                            {
                                _cur._req._reqs = new List <TopicReq>();
                            }
                            _cur._req._reqs.Add(this);
                            return;
                        }
                        else
                        {
                            _cur._req = this;
                        }
                    }
                    _cur.Connection.SendReq(4, this, _cur.path, 3);
                    return;
                }
                next = _cur.GetChild(name, false);
                if (next == null)
                {
                    if (_create)
                    {
                        _create = false;
                        if (_path.Length <= idx2 && _state != null)
                        {
                            _cur.Connection.SendReq(8, this, _path.Substring(0, idx2), _state, _manifest);
                        }
                        else
                        {
                            _cur.Connection.SendReq(8, this, _path.Substring(0, idx2));
                        }
                    }
                    else
                    {
                        _tcs.SetResult(null);
                        lock (_cur) {
                            _cur._req = null;
                            if (this._reqs != null)
                            {
                                foreach (var r in _reqs)
                                {
                                    App.PostMsg(r);
                                }
                            }
                        }
                    }
                    return;
                }
                _cur = next;
                App.PostMsg(this);
            }