Ejemplo n.º 1
0
        static void RegisterCurrentDemo(string groupKey, string demoKey)
        {
            DemoModel demo = null;

            if (IsIntroPage(groupKey, demoKey))
            {
                demo = DemosModel.Current.Intro;
            }
            else if (IsOverviewPage(demoKey) && String.IsNullOrEmpty(groupKey))
            {
                demo = DemosModel.Current.Overview;
            }
            else if (IsErrorPage(demoKey))
            {
                demo = CreateErrorPageDemoModel();
            }
            else
            {
                demo = DemosModel.Instance.FindDemo(DemosModel.Current.Key, groupKey, demoKey);
            }
            if (demo == null)
            {
                demo = CreateBogusDemoModel();
            }
            Context.Items[CurrentDemoKey] = demo;
            DevExpress.Web.Internal.DemoUtils.RegisterDemo(DemosModel.Current.Key, groupKey, demoKey);
        }
Ejemplo n.º 2
0
        public static string GetDemoTitleHtml(DemoModel demo)
        {
            string result = String.Format("{0} - {1}", demo.Group.Title, demo.Title);

            if (result.Length > 60)
            {
                result = demo.Title;
            }
            return(HttpUtility.HtmlEncode(result));
        }
Ejemplo n.º 3
0
 public static IEnumerable <SourceCodePage> GetSourceCodePages(DemoModel demo)
 {
     lock (sourceCodeCacheLock) {
         if (!sourceCodeCache.ContainsKey(demo))
         {
             sourceCodeCache[demo] = CreateSourceCodePages(demo);
         }
         return(sourceCodeCache[demo]);
     }
 }
Ejemplo n.º 4
0
 public SearchResult(DemoModel demo, int rank)
 {
     this.Demo = demo;
     this.Rank = rank;
     Product   = demo.Product;
     if (demo is DemoPageModel)
     {
         Group = (demo as DemoPageModel).Group;
     }
 }
Ejemplo n.º 5
0
        static string GenerateMvcDemoUrl(DemoModel demo)
        {
            StringBuilder builder = new StringBuilder("~/");

            if (!string.IsNullOrEmpty(demo.Group.Key))
            {
                builder.Append(demo.Group.Key);
                builder.Append("/");
            }
            builder.Append(demo.Key);
            return(builder.ToString());
        }
Ejemplo n.º 6
0
 public static string GenerateDemoUrl(DemoModel demo)
 {
     if (!string.IsNullOrEmpty(demo.HighlightedLink))
     {
         return(demo.HighlightedLink);
     }
     if (IsMvc)
     {
         return(GenerateMvcDemoUrl(demo));
     }
     return(GenerateWebFormsDemoUrl(demo));
 }
Ejemplo n.º 7
0
        static DemoModel CreateBogusDemoModel()
        {
            DemoGroupModel group = new DemoGroupModel();

            group.Title = "ASP.NET";

            DemoModel result = new DemoModel();

            result.Group          = group;
            result.HideSourceCode = true;
            result.Title          = "Delivered!";

            return(result);
        }
Ejemplo n.º 8
0
        static void RegisterCurrentDemo(string groupKey, string demoKey)
        {
            DemoModel      demo  = null;
            DemoGroupModel group = DemosModel.Current.FindGroup(groupKey);

            if (group != null)
            {
                demo = group.FindDemo(demoKey);
            }

            if (demo == null)
            {
                demo = CreateBogusDemoModel();
            }

            Context.Items[CurrentDemoKey] = demo;
        }
Ejemplo n.º 9
0
        public static string GetDemoTitleHtml(DemoModel demo)
        {
            string result = string.Empty;

            if (demo is DemoPageModel)
            {
                result = string.Format("{0} - {1}", ((DemoPageModel)demo).Group.Title, demo.Title);
            }
            if (string.IsNullOrEmpty(result))
            {
                result = demo.Title;
            }
            else if (result.Length > 60)
            {
                result = demo.Title;
            }
            return(HttpUtility.HtmlEncode(result));
        }
Ejemplo n.º 10
0
        static IEnumerable <SourceCodePage> CreateSourceCodePages(DemoModel demo)
        {
            List <SourceCodePage> result = new List <SourceCodePage>();

            if (IsMvc)
            {
                foreach (string fileName in demo.SourceFiles)
                {
                    if (fileName.StartsWith("~/Models/"))
                    {
                        AddSourceCodePage(result, string.Format("Model ({0})", Path.GetFileNameWithoutExtension(fileName)), fileName, false);
                    }
                }
                string controllerUrl = string.Format("~/Controllers/{0}/{0}Controller.{1}.cs", demo.Group.Key, demo.Key);
                AddSourceCodePage(result, "Controller", controllerUrl, true, false);
                string commonControllerUrl = string.Format("~/Controllers/{0}Controller.cs", demo.Group.Key);
                AddSourceCodePage(result, "Controller (common)", commonControllerUrl, false);
                string viewUrl = string.Format("~/Views/{0}/{1}.{2}", demo.Group.Key, demo.Key, IsMvcRazor ? "cshtml" : "aspx");
                AddSourceCodePage(result, "View", viewUrl, true, false);
                foreach (string fileName in demo.SourceFiles)
                {
                    if (fileName.StartsWith("~/Views/"))
                    {
                        AddSourceCodePage(result, string.Format("View ({0})", Path.GetFileNameWithoutExtension(fileName)), fileName, true);
                    }
                }
            }
            else
            {
                string baseUrl = GenerateWebFormsDemoUrl(demo);
                AddSourceCodePage(result, "ASPX", baseUrl, true);
                AddSourceCodePage(result, "C#", baseUrl + ".cs", CodeLanguage == "C#");
                AddSourceCodePage(result, "VB", baseUrl + ".vb", CodeLanguage == "VB");
                foreach (string fileName in demo.SourceFiles)
                {
                    AddSourceCodePage(result, Path.GetFileName(fileName), fileName, false);
                }
            }
            return(result);
        }
Ejemplo n.º 11
0
        public static string GenerateDemoUrl(DemoModel demo)
        {
            if (!string.IsNullOrEmpty(demo.HighlightedLink))
            {
                return(demo.HighlightedLink);
            }
            StringBuilder str = new StringBuilder();

            if (demo.Product.IsCurrent)
            {
                str.Append("~/");
            }
            else
            {
                var url        = HttpContext.Current.Request.Url.AbsolutePath;
                var productUrl = "/" + CurrentDemo.Product.Url;
                url = url.Substring(0, url.IndexOf(productUrl, StringComparison.InvariantCultureIgnoreCase) + 1);
                str.AppendFormat("{0}{1}/", url, demo.Product.Url);
            }
            DemoPageModel demoPage = demo as DemoPageModel;
            bool          hasDemoVirtualGroupKey = demoPage != null && !string.IsNullOrEmpty(demoPage.VirtualGroupKey);
            bool          hasGroupKey            = demoPage != null && demoPage.Group != null && !string.IsNullOrEmpty(demoPage.Group.Key);

            if (hasDemoVirtualGroupKey || hasGroupKey)
            {
                str.Append(GetDemoGroupKey(demoPage));
                str.Append("/");
            }
            if (!IsMvc || !string.Equals("Index", demo.Key))
            {
                str.Append(demo.Key);
            }
            if (!IsMvc)
            {
                str.Append(".aspx");
            }
            return(str.ToString());
        }
Ejemplo n.º 12
0
 int CompareHighlightedDemos(DemoModel x, DemoModel y)
 {
     return(Comparer <int> .Default.Compare(x.HighlightedIndex, y.HighlightedIndex));
 }
Ejemplo n.º 13
0
 int CompareHighlightedDemos(DemoModel x, DemoModel y) {
     return Comparer<int>.Default.Compare(x.HighlightedIndex, y.HighlightedIndex);
 }