public void GetObjectFromObjectValueLinkTest()
        {
            ILinks <TLinkAddress> links          = CreateLinks();
            var          defaultXmlStorage       = CreateXmlStorage(links);
            TLinkAddress document                = defaultXmlStorage.CreateDocument("documentName");
            TLinkAddress documentObjectValueLink = defaultXmlStorage.AttachObject(document);
            TLinkAddress objectValueLink         = links.GetTarget(documentObjectValueLink);
            TLinkAddress objectFromGetObject     = defaultXmlStorage.GetObject(objectValueLink);

            Assert.Equal(links.GetTarget(objectValueLink), objectFromGetObject);
        }
        public void AttachNullValueToKey()
        {
            ILinks <TLinkAddress> links             = CreateLinks();
            var                 defaultXmlStorage   = CreateXmlStorage(links);
            TLinkAddress        document            = defaultXmlStorage.CreateDocument("documentName");
            TLinkAddress        documentObjectValue = defaultXmlStorage.AttachObject(document);
            TLinkAddress        @object             = defaultXmlStorage.GetObject(documentObjectValue);
            TLinkAddress        memberLink          = defaultXmlStorage.AttachMemberToObject(@object, "keyName");
            TLinkAddress        memberNullValueLink = defaultXmlStorage.AttachNull(memberLink);
            TLinkAddress        nullValueLink       = links.GetTarget(memberNullValueLink);
            List <TLinkAddress> objectMembersLinks  = defaultXmlStorage.GetMembersLinks(@object);

            Assert.Equal(nullValueLink, defaultXmlStorage.GetValueLink(objectMembersLinks[0]));
        }
Exemple #3
0
        public static string FromSequenceLinkToString(ulong link, ILinks<ulong> links)
        {
            var sb = new StringBuilder();

            if (links.Exists(link))
            {
                StopableSequenceWalker.WalkRight(link, links.GetSource, links.GetTarget,
                    x => x <= MapSize || links.GetSource(x) == x || links.GetTarget(x) == x, element =>
                    {
                        sb.Append(FromLinkToChar(element));
                        return true;
                    });
            }

            return sb.ToString();
        }
        public void AttachArrayValueToKey()
        {
            ILinks <TLinkAddress> links      = CreateLinks();
            var          defaultXmlStorage   = CreateXmlStorage(links);
            TLinkAddress document            = defaultXmlStorage.CreateDocument("documentName");
            TLinkAddress documentObjectValue = defaultXmlStorage.AttachObject(document);
            TLinkAddress @object             = defaultXmlStorage.GetObject(documentObjectValue);
            TLinkAddress memberLink          = defaultXmlStorage.AttachMemberToObject(@object, "keyName");
            TLinkAddress arrayElement        = defaultXmlStorage.CreateString("arrayElement");

            TLinkAddress[]      array = { arrayElement, arrayElement, arrayElement };
            TLinkAddress        memberArrayValueLink = defaultXmlStorage.AttachArray(memberLink, array);
            TLinkAddress        arrayValueLink       = links.GetTarget(memberArrayValueLink);
            List <TLinkAddress> objectMembersLinks   = defaultXmlStorage.GetMembersLinks(@object);

            Assert.Equal(memberLink, objectMembersLinks[0]);
            Assert.Equal(arrayValueLink, defaultXmlStorage.GetValueLink(objectMembersLinks[0]));
        }
 public static string Format <TLink>(this ILinks <TLink> links, TLink link) => $"({link}: {links.GetSource(link)}->{links.GetTarget(link)})";