protected virtual string GetUrl(ShortcutNode shortcut)
        {
            var applicationPath = GetApplicationPath(shortcut);

            if (applicationPath != null)
            {
                return(applicationPath.ExternalUrl ?? applicationPath.AbsolutePath);
            }

            return(null);
        }
        private void PopulatePresets(MenuItem item = null, ShortcutNode node = null)
        {
            MenuItem currentItem = item ?? menuPresets;

            foreach (IShortcut shortcut in node?.Children ?? Global.PluginManager.PredefinedShortcuts)
            {
                MenuItem newItem = new MenuItem {
                    Header = shortcut.Title, Tag = shortcut
                };
                newItem.Click += ShortcutPresetClick;
                if (shortcut is ShortcutNode)
                {
                    PopulatePresets(newItem, (ShortcutNode)shortcut);
                }
                currentItem.Items.Add(newItem);
            }
        }
        private static string GetShortcutDescription(ShortcutNode shortcut)
        {
            if (!string.IsNullOrWhiteSpace(shortcut.Description))
            {
                return(shortcut.Description);
            }
            if (shortcut.WebPage != null && !shortcut.WebPage.IsReference)
            {
                return(shortcut.WebPage.Summary);
            }
            if (shortcut.WebFile != null && !shortcut.WebFile.IsReference)
            {
                return(shortcut.WebFile.Summary);
            }

            return(null);
        }
        private ApplicationPath GetApplicationPath(ShortcutNode shortcut)
        {
            if (shortcut.WebPage != null && !shortcut.WebPage.IsReference)
            {
                return(GetApplicationPath(shortcut.WebPage));
            }

            if (shortcut.WebFile != null && !shortcut.WebFile.IsReference)
            {
                return(GetApplicationPath(shortcut.WebFile));
            }

            if (!string.IsNullOrEmpty(shortcut.ExternalUrl))
            {
                return(ApplicationPath.FromExternalUrl(shortcut.ExternalUrl));
            }

            return(null);
        }
        private static bool TryAssert(ShortcutNode shortcut)
        {
            if (!shortcut.DisableTargetValidation.GetValueOrDefault())
            {
                if (shortcut.WebPage != null && !shortcut.WebPage.IsReference)
                {
                    return(TryAssert(shortcut.WebPage.PublishingState));
                }

                if (shortcut.WebFile != null && !shortcut.WebFile.IsReference)
                {
                    return(TryAssert(shortcut.WebFile.PublishingState));
                }
            }

            if (shortcut.Parent != null && !shortcut.Parent.IsReference)
            {
                return(TryAssert(shortcut.Parent.PublishingState));
            }

            return(false);
        }
        protected virtual CrmSiteMapNode GetNode(ContentMap map, ShortcutNode shortcut, HttpStatusCode statusCode, IContentMapEntityUrlProvider provider)
        {
            var entity = shortcut.ToEntity(GetEntityType("adx_shortcut"));

            var url = !string.IsNullOrWhiteSpace(shortcut.ExternalUrl) ? shortcut.ExternalUrl : provider.GetUrl(map, shortcut);

            if (url == null)
            {
                return(null);
            }

            var description = GetShortcutDescription(shortcut);

            return(new CrmSiteMapNode(
                       this,
                       url,
                       url,
                       !string.IsNullOrWhiteSpace(shortcut.Title) ? shortcut.Title : shortcut.Name,
                       description,
                       null,
                       shortcut.ModifiedOn.GetValueOrDefault(DateTime.UtcNow),
                       entity,
                       statusCode));
        }
 protected virtual CrmSiteMapNode GetNode(ContentMap map, ShortcutNode shortcut, IContentMapEntityUrlProvider provider)
 {
     return(GetNode(map, shortcut, HttpStatusCode.OK, provider));
 }