Exemple #1
0
        /// <summary>
        /// Constructs a new root-DebugResponse-node.
        /// </summary>
        /// <param name="name">The name of the Node.</param>
        /// <param name="description">The description for the node.</param>
        /// <param name="getElementFunc">The function to call whenever the contents of the node will be requested.</param>
        /// <returns>A root-DebugResponse-node.</returns>
        public static DebugContainerResponseNode ConstructRootNode(string name, string description = null, Func <SessionData, HElement> getElementFunc = null)
        {
            DebugContainerResponseNode ret = new DebugContainerResponseNode();

            ret.Name         = name;
            ret._description = description;
            ret._subNodes    = new AVLTree <ID, DebugResponseNode>();
            ret.GetElements  = getElementFunc ?? (s => new HPlainText());
            ret.SetRootNode();

            return(ret);
        }
Exemple #2
0
        /// <summary>
        /// Sets the the current node as Child of a given DebugContainerResponseNode.
        /// </summary>
        /// <param name="node">The parent node for this node.</param>
        internal void SetParentURL(DebugContainerResponseNode node)
        {
            // We don't want to expose this to someone who does not know how exactly this works. Please just use 'parentNode.AddNode(this);' to add this node to a parentNode.

            if (URL != null)
            {
                if (_parentNode != null)
                {
                    Logger.LogTrace($"SetParentURL: A DebugNodes parent is being modified and it will not be accessible anymore via the old URL. (The URL is changing from '{URL}' to '{node.URL}/{ID}'.)");
                    _parentNode.RemoveNode(this);
                }
            }

            if (node == null)
            {
                URL = new URL <ID>(new ID[] { ID });
            }
            else
            {
                URL = node.URL.Append(ID);
            }

            _parentNode = node;
        }
Exemple #3
0
        /// <summary>
        /// Creates a new DebugContainerResponseNode.
        /// </summary>
        /// <param name="name">The name of this DebugResponseNode.</param>
        /// <param name="description">The description for this DebugResponseNode.</param>
        /// <param name="getElementFunc">The function to execute whenever the contents of this DebugResponseNode are requested.</param>
        /// <param name="parentNode">The parent node of this node.</param>
        /// <param name="AddToParent">Shall this node be added to it's parent already?</param>
        public DebugContainerResponseNode(string name, string description = null, Func <SessionData, HElement> getElementFunc = null, DebugContainerResponseNode parentNode = null, bool AddToParent = true)
        {
            Name         = name;
            _description = description;
            _subNodes    = new AVLTree <ID, DebugResponseNode>();
            GetElements  = getElementFunc ?? (s => new HText($"No {nameof(GetElements)} function was specified."));

            if (AddToParent)
            {
                if (parentNode == null)
                {
                    DebugResponse.AddNode(this);
                }
                else
                {
                    parentNode.AddNode(this);
                }
            }
        }