public static string ToHtml(IPrintable printable)
        {
            Dictionary <string, IPrintable> map = printable.GetItems();
            string name = SecurityElement.Escape(printable.ToString());

            if (map == null || map.Count == 0)
            {
                return(name);
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<div>");
            //if (printable is ReflectionPrintable) sb.AppendFormat("<b>{0}</b><br />\n", name);
            foreach (var item in map)
            {
                string key      = SecurityElement.Escape(item.Key);
                string itemHtml = ToHtml(item.Value);
                if (!(item.Value is LeafPrintable))
                {
                    itemHtml = "\n" + string.Join("\n", itemHtml.Split('\n').Select(x => "  " + x));
                    sb.AppendFormat("<i>{0}</i>: <a href='#' onclick='toggle(this); return false;'>{1}</a>\n", key, SecurityElement.Escape(item.Value.ToString()));
                    sb.AppendFormat("<div class='hidden'>{0}</div>\n", itemHtml);
                }
                else
                {
                    sb.AppendFormat("<i>{0}</i>: {1}<br/>\n", key, itemHtml);
                }
            }
            sb.AppendLine("</div>");

            return(sb.ToString());
        }
Example #2
0
        public String ToString(IEntityEquals left, IPrintable printable)
        {
            StringBuilder sb = new StringBuilder();

            printable.ToString(sb);
            return(sb.ToString());
        }
Example #3
0
        protected void ToStringIntern(StringBuilder sb, IPrintable preSpace, bool?entityDescriptionAtRoot)
        {
            Object[] cacheValues = this.cacheValues;

            if (entityDescriptionAtRoot == null)
            {
                IObjRef[] objRefs = this.objRefs;
                for (int a = 0, size = objRefs.Length; a < size; a++)
                {
                    IObjRef objRef = objRefs[a];
                    sb.Append(pipe).Append(' ').Append(a + 1);
                    sb.Append(". Type=").Append(objRef.RealType.Name);
                    sb.Append(" Id(");
                    if (objRef.IdNameIndex == ObjRef.PRIMARY_KEY_INDEX)
                    {
                        sb.Append("PK");
                    }
                    else
                    {
                        sb.Append("AK-").Append(objRef.IdNameIndex);
                    }
                    sb.Append(")=").Append(objRef.Id);
                    entityDescriptionAtRoot = true;
                    preSpace.ToString(sb);
                }
            }
            sb.Append(pipe).Append(" Cache");
            bool firstSuffix = true;

            if (!privileged)
            {
                firstSuffix = AppendSuffix("SEC", firstSuffix, sb);
            }
            if (transactional)
            {
                firstSuffix = AppendSuffix("TX", firstSuffix, sb);
            }
            if (threadLocal)
            {
                firstSuffix = AppendSuffix("L", firstSuffix, sb);
            }
            if (parentEntry == null)
            {
                firstSuffix = AppendSuffix("G", firstSuffix, sb);
            }
            sb.Append("--#0x").Append(ToHexString(cache));

            IPrintable oldPreSpace = preSpace;

            preSpace = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
            {
                oldPreSpace.ToString(sb2);
                sb2.Append('\t');
            }));
            IPrintable preSpaceForCacheValue;

            if (childEntries == null)
            {
                preSpaceForCacheValue = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
                {
                    preSpace.ToString(sb2);
                    sb2.Append("   ");
                }));
            }
            else
            {
                preSpaceForCacheValue = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
                {
                    preSpace.ToString(sb2);
                    sb2.Append("|  ");
                }));
            }
            for (int a = 0, size = cacheValues.Length; a < size; a++)
            {
                preSpaceForCacheValue.ToString(sb);
                sb.Append(a + 1).Append('.');
                Object cacheValue = cacheValues[a];
                if (cacheValue == null)
                {
                    sb.Append(" n/a");
                    continue;
                }
                IEntityMetaData metaData = ((IEntityMetaDataHolder)cacheValue).Get__EntityMetaData();
                Object          id, version = null;
                bool            hasVersion        = metaData.VersionMember != null;
                bool            hasPendingChanges = false;
                if (cacheValue is AbstractCacheValue)
                {
                    AbstractCacheValue cacheValueCasted = (AbstractCacheValue)cacheValue;
                    id = cacheValueCasted.Id;
                    if (hasVersion)
                    {
                        version = cacheValueCasted.Version;
                    }
                }
                else
                {
                    id = metaData.IdMember.GetValue(cacheValue);
                    if (hasVersion)
                    {
                        version = metaData.VersionMember.GetValue(cacheValue);
                    }
                    hasPendingChanges = this.pendingChanges != null && this.pendingChanges[a];
                }
                if (!entityDescriptionAtRoot.HasValue || !entityDescriptionAtRoot.Value)
                {
                    sb.Append(" Type=").Append(metaData.EntityType.Name);
                    sb.Append(" Id=").Append(id);
                }
                if (hasVersion)
                {
                    sb.Append(" Version=").Append(version);
                }
                if (hasPendingChanges)
                {
                    sb.Append(" (m)");
                }
            }
            if (this.childEntries is CacheWalkerResult[])
            {
                CacheWalkerResult[] childEntries2 = (CacheWalkerResult[])this.childEntries;
                for (int a = 0, size = childEntries2.Length; a < size; a++)
                {
                    bool hasSuccessor       = a < size - 1;
                    CacheWalkerResult entry = childEntries2[a];

                    IPrintable preSpaceForChildEntry = new PrintableDelegateWrapper(new PrintableDelegate(delegate(StringBuilder sb2)
                    {
                        preSpace.ToString(sb2);
                        if (hasSuccessor)
                        {
                            sb2.Append("|");
                        }
                    }));
                    preSpace.ToString(sb);
                    entry.ToStringIntern(sb, preSpaceForChildEntry, entityDescriptionAtRoot);
                }
            }
            else if (this.childEntries != null)
            {
                CacheWalkerResult entry = (CacheWalkerResult)this.childEntries;
                preSpace.ToString(sb);
                entry.ToStringIntern(sb, preSpace, entityDescriptionAtRoot);
            }
        }