Пример #1
0
        /// <inheritdoc />
        public override HElement GetContents(SessionData sessionData, string requestedAction, WalkableQueue <Tuple <ID, string> > positionQueue)
        {
            if (positionQueue.AtEnd())
            {
                HElement list = new HList(HList.EListType.UnorderedList, (from s in _subNodes select GetLink(s.Value.Name, s.Key, positionQueue, positionQueue.Position, null)).ToArray())
                {
                    Class = "subnodes"
                };

                if (((HList)list).IsEmpty())
                {
                    list = new HItalic("This DebugNode includes no Subnodes.")
                    {
                        Class = "subnodes"
                    }
                }
                ;
                else
                {
                    list = new HHeadline("Subnodes of this DebugNode", 3)
                    {
                        Class = "subnodes"
                    }
                } +list;

                return(new HHeadline(Name) + new HLine()
                {
                    Class = "start"
                } +(_description == null ? new HText(_description) : (HElement) new HString()) + new HContainer(GetElements(sessionData)) + new HLine()
                {
                    Class = "subnodes"
                } +list);
            }
            else
            {
                HLink navlink = GetLink(this);
                navlink.Class = "nav";
                HInlineContainer name = new HInlineContainer()
                {
                    Elements = { navlink }
                };

                DebugResponseNode node = null;

                positionQueue.Pop();

                if (_subNodes)
                {
                    node = _subNodes[positionQueue.Peek().Item1];
                }

                if (ReferenceEquals(node, null))
                {
                    HElement list = new HList(HList.EListType.UnorderedList, (from s in _subNodes select GetLink(s.Value.Name, s.Value.URL)).ToArray())
                    {
                        Class = "subnodes"
                    };

                    if (((HList)list).IsEmpty())
                    {
                        list = new HItalic("This DebugNode includes no Subnodes.")
                        {
                            Class = "subnodes"
                        }
                    }
                    ;
                    else
                    {
                        list = new HHeadline("Subnodes of this DebugNode", 3)
                        {
                            Class = "subnodes"
                        }
                    } +list;

                    return(name + new HHeadline(Name) + new HLine()
                    {
                        Class = "start"
                    } +new HText($"The ID '{positionQueue.Peek().Item1.Value}' is not a child of this {nameof(DebugContainerResponseNode)}.")
                    {
                        Class = "invalid"
                    } +new HLine()
                    {
                        Class = "subnodes"
                    } +list);
                }
                else
                {
                    return(name + node.GetContents(sessionData, positionQueue.Peek().Item2, positionQueue));
                }
            }
        }
        private HElement GetDebugResponse(SessionData sessionData)
        {
            HMultipleElements ret = new HMultipleElements();

            ret += new HText($"Current Response Count: {StringResponses.Count} ({CurrentStringResponseCacheSize * sizeof(char)} bytes).");

            if (MaximumStringResponseCacheSize > 0)
            {
                ret += new HText($"Cache Fillrate: {CurrentStringResponseCacheSize} / {MaximumStringResponseCacheSize} = {((CurrentStringResponseCacheSize / MaximumStringResponseCacheSize) * 100f):0.000}%.");

                string request;

                using (StringResponseLock.LockRead())
                {
                    if (sessionData.HttpHeadVariables.TryGetValue("key", out request))
                    {
                        ret += new HButton("Back to all entries", "?all=true");

                        ResponseCacheEntry <string> response;

                        if (StringResponses.TryGetValue(request, out response))
                        {
                            ret += new HHeadline($"Entry '{request}'", 2);
                            ret += new HText("Requested Times: " + response.Count);
                            ret += new HText("Response Length: " + response.Response.Length);
                            ret += new HText("Last Requested: " + response.LastRequestedDateTime);
                            ret += new HText("Last Updated Times: " + response.LastUpdatedDateTime);
                            ret += new HText("Lifetime: " + response.RefreshTime);

                            ret += new HLine();
                            ret += new HText("Contents:");

                            ret += new HText(response.Response)
                            {
                                Class = "code"
                            };
                        }
                        else
                        {
                            ret += new HText($"The requested entry '{request}' could not be found.")
                            {
                                Class = "error"
                            };
                        }
                    }
                    else if (sessionData.HttpHeadVariables.ContainsKey("all"))
                    {
                        ret += new HTable((from e in StringResponses
                                           select new object[] { e.Key, e.Value.Count, e.Value.Response.Length, e.Value.LastRequestedDateTime, e.Value.LastUpdatedDateTime, e.Value.RefreshTime, new HLink("Show Contents", "?key=" + e.Key.EncodeUrl()) }
                                           ).OrderByDescending(e => (int)(ulong)e[1] * (int)e[2]))
                        {
                            TableHeader = new string[] { "Key", "Request Count", "Response Length", "Last Request Time", "Last Updated Time", "Lifetime", "Contents" }
                        };
                    }
                    else
                    {
                        ret += new HButton("Show all entries (might take a long time to load)", HButton.EButtonType.button, "?all=true");
                    }
                }
            }

            return(ret);
        }