コード例 #1
0
        public static IHtmlContent WidgetLink(this IHtmlHelper html, NavigationWidget widget, string product)
        {
            var href = html.ExampleUrl(widget.Items[0]);

            var text = widget.Text;

            StringBuilder link = new StringBuilder();

            link.AppendFormat("<a href=\"{0}\">", href);
            link.Append(text);

            if (widget.Beta)
            {
                link.Append("<span class=\"beta-widget\"></span>");
            }

            if (widget.New)
            {
                link.Append("<span class=\"new-widget\"></span>");
            }

            if (widget.Updated)
            {
                link.Append("<span class=\"updated-widget\"></span>");
            }

            link.Append("</a>");

            return(html.Raw(link.ToString()));
        }
コード例 #2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            FindCurrentExample();

            NavigationExample currentExample = ViewBag.CurrentExample;
            NavigationWidget  currentWidget  = ViewBag.CurrentWidget;

            if (currentWidget == null)
            {
                return;
            }

            ViewBag.Description = Description(ViewBag.Product, currentExample, currentWidget);

            var exampleFiles = new List <ExampleFile>();

            exampleFiles.AddRange(SourceCode());
            exampleFiles.AddRange(AdditionalSources(currentWidget.Sources));
            exampleFiles.AddRange(AdditionalSources(currentExample.Sources));
            ViewBag.ExampleFiles = exampleFiles.Where(file => file.Exists(ContentRootPath));

            if (currentWidget.Documentation != null && currentWidget.Documentation.ContainsKey(ViewBag.Product))
            {
                ViewBag.Documentation = "http://docs.telerik.com/aspnet-core/" + currentWidget.Documentation[ViewBag.Product];
            }

            if (currentWidget.Forum != null && currentWidget.Forum.ContainsKey(ViewBag.Product))
            {
                ViewBag.Forum = "http://www.telerik.com/forums/" + currentWidget.Forum[ViewBag.Product];
            }
        }
コード例 #3
0
        protected void FindCurrentExample()
        {
            var found = false;

            NavigationExample current       = null;
            NavigationWidget  currentWidget = null;

            foreach (NavigationWidget widget in ViewBag.Navigation)
            {
                foreach (NavigationExample example in widget.Items)
                {
                    if (example.ShouldInclude())
                    {
                        examplesUrl.Add("~/" + example.Url);
                    }

                    if (!found && IsCurrentExample(example.Url))
                    {
                        current       = example;
                        currentWidget = widget;
                        found         = true;
                    }
                }
            }

            ViewBag.CurrentWidget = currentWidget;

            if (currentWidget == null)
            {
                return;
            }

            ViewBag.CurrentExample = current;

            if (current.Title != null)
            {
                if (current.Title.ContainsKey(MvcFlavor.AspNetCore))
                {
                    ViewBag.Title = current.Title[MvcFlavor.AspNetCore];
                }
            }
            else
            {
                ViewBag.Title = current.Text;
            }

            if (current.Meta != null)
            {
                if (current.Meta.ContainsKey(MvcFlavor.AspNetCore))
                {
                    ViewBag.Meta = current.Meta[MvcFlavor.AspNetCore];
                }
            }
        }
コード例 #4
0
        protected string Description(string product, NavigationExample example, NavigationWidget widget)
        {
            if (example.Description != null && example.Description.ContainsKey(product))
            {
                return(example.Description[product]);
            }
            else if (widget.Description != null && widget.Description.ContainsKey(product))
            {
                return(widget.Description[product]);
            }

            return(null);
        }
コード例 #5
0
 public NavigationWidgetViewModel(IEnumerable <NavigationEntity> navigation, NavigationWidget widget)
 {
     _navs  = navigation;
     Widget = widget;
 }
コード例 #6
0
 public NavigationWidgetViewModel(IEnumerable<NavigationEntity> navigation, NavigationWidget widget)
 {
     Navigations = navigation;
     Widget = widget;
 }