Пример #1
0
        public async Task<T> Post<T>(T d7Node, 
                                     CancellationToken cancelToken) 
            where T : D7NodeBase, new()
        {
            if (!IsLoggedIn)
                throw Error.BadAct($"‹{this.GetType().Name}› is not logged in.");

            if (_client == null) throw Error.NullRef("_client");
            IRequestShim req = null;
            try {
                req = _auth.Req.POST(URL.Api_EntityNode);
                d7Node.uid = this.CurrentUser.uid;
                req.Body = d7Node;
            }
            catch (Exception ex) { LogError("req = _auth.Req.POST", ex); return null; }



            //Trace_n("Creating new node on server...", "");
            T d7n = default(T); string m;
            try
            {
                //d7n = await _client.Send<T>(req, cancelToken, "",
                //    "Successfully created new «{0}»: [nid: {1}] “{2}”",
                //        x => x?.type, x => x?.nid, x => x?.title);
                d7n = await _client.Send<T>(req, cancelToken);
            }
            catch (RestServiceException ex) { OnNodeAdd.Err(this, ex); }
            catch (Exception ex) { OnUnhandled.Err(this, ex); }

            if (d7n.IsValidNode(out m))
                return d7n;
            else
                return Error_(d7n, "Invalid node.", m);
        }
Пример #2
0
        public virtual void Add(N newNode)
        {
            if (!allNodes.Contains(newNode))
            {
                newNode.Owner = this as G;
                allNodes.Add(newNode);
                OnNodeAdd?.Invoke(newNode);

                if (StartOrRootNode == null)
                {
                    StartOrRootNode = newNode;
                }
            }
            else
            {
                Debug.LogError("[HierarchicalGraph:Add()] -> Already contains this node.");
            }
        }
Пример #3
0
 protected void invokeOnNodeAddEvent(N node)
 {
     OnNodeAdd?.Invoke(node);
 }