enhance: Optimized the ScrollViewer style.
This commit is contained in:
1 parent
17c2b8473b
commit
51f07648ee
16 files changed
+458
-235
No files matched your search
@@ -16,22 +16,21 @@ public class DataService
|
||||
{
|
||||
var infoList = new List<DemoInfoModel>();
|
||||
string jsonStr = ReadEmbeddedJsonFile("HandyControlDemo.Data.DemoInfo.json");
|
||||
var jsonObj = JsonConvert.DeserializeObject<dynamic>(jsonStr);
|
||||
dynamic? jsonObj = JsonConvert.DeserializeObject<dynamic>(jsonStr);
|
||||
if (jsonObj is null)
|
||||
{
|
||||
return new List<DemoInfoModel>();
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach (var item in jsonObj)
|
||||
foreach (dynamic? item in jsonObj)
|
||||
{
|
||||
var titleKey = (string) item.title;
|
||||
var title = titleKey;
|
||||
string? titleKey = (string) item.title;
|
||||
List<DemoItemModel> list = Convert2DemoItemList(item.demoItemList);
|
||||
|
||||
var demoInfoModel = new DemoInfoModel
|
||||
{
|
||||
Key = titleKey,
|
||||
Title = title,
|
||||
Title = titleKey,
|
||||
DemoItemList = list,
|
||||
SelectedIndex = (int) item.selectedIndex,
|
||||
IsGroupEnabled = (bool) item.group
|
||||
@@ -43,10 +42,10 @@ public class DataService
|
||||
return infoList;
|
||||
}
|
||||
|
||||
private string ReadEmbeddedJsonFile(string resourceName)
|
||||
private static string ReadEmbeddedJsonFile(string resourceName)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
var resourceNameWithNamespace = assembly.GetManifestResourceNames()
|
||||
string? resourceNameWithNamespace = assembly.GetManifestResourceNames()
|
||||
.FirstOrDefault(n => n.EndsWith(resourceName, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (resourceNameWithNamespace is null)
|
||||
@@ -64,17 +63,17 @@ public class DataService
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
|
||||
private List<DemoItemModel> Convert2DemoItemList(dynamic list)
|
||||
private static List<DemoItemModel> Convert2DemoItemList(dynamic list)
|
||||
{
|
||||
var resultList = new List<DemoItemModel>();
|
||||
|
||||
foreach (var item in list)
|
||||
foreach (dynamic? item in list)
|
||||
{
|
||||
var name = (string) item[0];
|
||||
string? name = (string) item[0];
|
||||
string targetCtlName = item[1];
|
||||
string imageBrushName = item[2];
|
||||
var isNew = !string.IsNullOrEmpty((string) item[3]);
|
||||
var groupName = (string) item[4];
|
||||
bool isNew = !string.IsNullOrEmpty((string) item[3]);
|
||||
string? groupName = (string) item[4];
|
||||
if (string.IsNullOrEmpty(groupName))
|
||||
{
|
||||
groupName = "Misc";
|
||||
|
||||
Reference in new issue
Block a user