Ejemplo n.º 1
0
        public bool TryGetLink(IDocument from, MemberId id, out Link?link)
        {
            // map id -> model item
            var modelItem = m_Model.TryGetDocumentation(id);

            if (modelItem == null)
            {
                link = default;
                return(false);
            }

            // map model  -> page
            var page = m_PageFactory.TryGetPage(modelItem);

            if (page == null)
            {
                link = default;
                return(false);
            }

            // get link between pages
            var relativePath = m_DocumentSet.GetRelativePath(from, page);

            if (page.TryGetAnchor(id, out var anchor))
            {
                link = new Link(relativePath, anchor);
            }
            else
            {
                link = new Link(relativePath);
            }

            return(true);
        }