forked from syncfusion/blazor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
160 lines (139 loc) · 5.29 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace ej2_blazor_samples
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
internal class SampleListType
{
public string UID { get; set; }
public List<SampleListType> SourceData { get; set; }
public string Name { get; set; }
public string IconCss { get; set; }
public bool Expanded { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public SampleType Type { get; set; }
public List<Sample> Samples { get; set; }
}
internal class SampleList
{
public string Name { get; set; }
public string Directory { get; set; }
public string Category { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public SampleType Type { get; set; }
public int Order { get; set; }
public int UID { get; set; }
public List<Sample> Samples { get; set; } = new List<Sample>();
public String ControllerName { get; set; }
}
internal class Sample
{
public string Name { get; set; }
public string Directory { get; set; }
public string Category { get; set; }
public int Order { get; set; }
public string FileName { get; set; }
public string Url { get; set; }
public string TitleTag { get; set; }
public string MetaDescription { get; set; }
public string[] ActionDescription { get; set; }
public string[] Description { get; set; }
public List<SourceCollection> SourceFiles { get; set; } = new List<SourceCollection>();
[JsonConverter(typeof(StringEnumConverter))]
public SampleType Type { get; set; }
}
internal class SourceCollection
{
public string FileName { get; set; }
public string Id { get; set; }
}
internal static class SampleBrowser
{
public static List<SampleList> SampleList { get; set; } = new List<SampleList>();
internal static SampleConfig Config = new SampleConfig();
internal static string CurrentSampleName;
internal static List<Sample> CurrentControl = new List<Sample>();
internal static string CurrentControlName;
internal static string CurrentControlCategory;
internal static string CurrentFilePath;
internal static string CurrentUrl;
internal static string TitleTag;
internal static string MetaDescription;
internal static string[] ActionDescription;
internal static string[] Description;
internal static List<String> SampleUrls = new List<String>();
internal static void UpdateSampleData(string url)
{
string[] splittedUrl = url.Substring(0, url.IndexOf("?") >= 0 ? url.IndexOf("?") : url.Length).Split("/");
string CategoryName = splittedUrl[splittedUrl.Length - 2];
string SampleName = splittedUrl[splittedUrl.Length - 1];
foreach (var Control in SampleBrowser.SampleList)
{
if (Control.ControllerName == CategoryName)
{
SampleBrowser.CurrentControl = Control.Samples;
SampleBrowser.CurrentControlName = Control.Name;
SampleBrowser.CurrentControlCategory = Control.Category;
break;
}
}
foreach (var sample in SampleBrowser.CurrentControl)
{
if (sample.Url.IndexOf(SampleName) >= 0)
{
SampleBrowser.CurrentSampleName = sample.Name;
SampleBrowser.TitleTag = sample.TitleTag;
SampleBrowser.MetaDescription = sample.MetaDescription;
SampleBrowser.ActionDescription = sample.ActionDescription;
SampleBrowser.Description = sample.Description;
break;
}
}
}
}
internal class SampleData
{
public List<SampleList> SampleList { get; set; } = new List<SampleList>();
//internal SampleConfig Config = SampleBrowser.SampleList
internal string CurrentSampleName;
internal List<Sample> CurrentControl;
internal string CurrentControlName;
internal string CurrentControlCategory;
internal string CurrentFilePath;
internal string CurrentUrl;
internal string TitleTag;
internal string MetaDescription;
internal string[] ActionDescription;
internal string[] Description;
internal List<String> SampleUrls = new List<String>();
}
enum SampleType
{
None,
New,
Updated,
Preview
}
}