diff --git a/Samples/XamlUIBasics/cs/AppUIBasics.Droid/AppUIBasics.Droid.csproj b/Samples/XamlUIBasics/cs/AppUIBasics.Droid/AppUIBasics.Droid.csproj index f06734e0..fc11da38 100644 --- a/Samples/XamlUIBasics/cs/AppUIBasics.Droid/AppUIBasics.Droid.csproj +++ b/Samples/XamlUIBasics/cs/AppUIBasics.Droid/AppUIBasics.Droid.csproj @@ -66,8 +66,8 @@ - - + + diff --git a/Samples/XamlUIBasics/cs/AppUIBasics.Shared/DataModel/ControlInfoDataSource.cs b/Samples/XamlUIBasics/cs/AppUIBasics.Shared/DataModel/ControlInfoDataSource.cs index 67d6ebe7..75c2eef4 100644 --- a/Samples/XamlUIBasics/cs/AppUIBasics.Shared/DataModel/ControlInfoDataSource.cs +++ b/Samples/XamlUIBasics/cs/AppUIBasics.Shared/DataModel/ControlInfoDataSource.cs @@ -11,14 +11,14 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; +using System.Json; using System.Linq; using System.Reflection; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Windows.Storage; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media.Imaging; +using System.Runtime.Serialization.Json; // The data model defined by this file serves as a representative example of a strongly-typed // model. The property names chosen coincide with data bindings in the standard item templates. @@ -193,54 +193,61 @@ namespace AppUIBasics.Data using (var s = new StreamReader(this.GetType().GetTypeInfo().Assembly.GetManifestResourceStream(name))) { - var jsonObject = JObject.Parse(s.ReadToEnd()); + var jsonObject = JsonObject.Load(s); var jsonArray = jsonObject["Groups"]; lock (_lock) { - foreach (JObject groupObject in jsonArray) + foreach (JsonValue groupValue in jsonArray) { - var group = new ControlInfoDataGroup(groupObject["UniqueId"].Value(), - groupObject["Title"].Value(), - groupObject["Subtitle"].Value(), - groupObject["ImagePath"].Value(), - groupObject["Description"].Value()); - - foreach (JObject itemValue in groupObject["Items"]) + if (groupValue is JsonObject groupObject) { - var itemObject = itemValue; - var item = new ControlInfoDataItem(itemObject["UniqueId"].Value(), - itemObject["Title"].Value(), - itemObject["Subtitle"].Value(), - itemObject["ImagePath"].Value(), - itemObject["Description"].Value(), - itemObject["Content"].Value(), - itemObject["IsNew"].Value()); + ControlInfoDataGroup group = new ControlInfoDataGroup(groupObject["UniqueId"], + groupObject["Title"], + groupObject["Subtitle"], + groupObject["ImagePath"], + groupObject["Description"]); - if (itemObject.ContainsKey("Docs")) + foreach (JsonValue itemValue in groupObject["Items"]) { - foreach (JObject docValue in itemObject["Docs"]) + if (itemValue is JsonObject itemObject) { - var docObject = docValue; - item.Docs.Add(new ControlInfoDocLink(docObject["Title"].Value(), docObject["Uri"].Value())); + var item = new ControlInfoDataItem(itemObject["UniqueId"], + itemObject["Title"], + itemObject["Subtitle"], + itemObject["ImagePath"], + itemObject["Description"], + itemObject["Content"], + itemObject["IsNew"]); + + if (itemObject.ContainsKey("Docs")) + { + foreach (JsonValue docValue in itemObject["Docs"]) + { + if (docValue is JsonObject docObject) + { + item.Docs.Add(new ControlInfoDocLink(docObject["Title"], docObject["Uri"])); + } + } + } + + if (itemObject.ContainsKey("RelatedControls")) + { + foreach (JsonValue relatedControlValue in itemObject["RelatedControls"]) + { + item.RelatedControls.Add(relatedControlValue); + } + } + + group.Items.Add(item); } } - if (itemObject.ContainsKey("RelatedControls")) + if (!Groups.Any(g => g.Title == group.Title)) { - foreach (JValue relatedControlValue in itemObject["RelatedControls"]) - { - item.RelatedControls.Add(relatedControlValue.Value()); - } + Groups.Add(group); } - - group.Items.Add(item); - } - - if (!Groups.Any(g => g.Title == group.Title)) - { - Groups.Add(group); } } } @@ -268,21 +275,21 @@ namespace AppUIBasics.Data foreach (JsonValue groupValue in jsonArray) { JsonObject groupObject = groupValue.GetObject(); - ControlInfoDataGroup group = new ControlInfoDataGroup(groupObject["UniqueId"].Value(), - groupObject["Title"].Value(), - groupObject["Subtitle"].Value(), - groupObject["ImagePath"].Value(), - groupObject["Description"].Value()); + ControlInfoDataGroup group = new ControlInfoDataGroup(groupObject["UniqueId"], + groupObject["Title"], + groupObject["Subtitle"], + groupObject["ImagePath"], + groupObject["Description"]); foreach (JsonValue itemValue in groupObject["Items"].GetArray()) { JsonObject itemObject = itemValue.GetObject(); - var item = new ControlInfoDataItem(itemObject["UniqueId"].Value(), - itemObject["Title"].Value(), - itemObject["Subtitle"].Value(), - itemObject["ImagePath"].Value(), - itemObject["Description"].Value(), - itemObject["Content"].Value(), + var item = new ControlInfoDataItem(itemObject["UniqueId"], + itemObject["Title"], + itemObject["Subtitle"], + itemObject["ImagePath"], + itemObject["Description"], + itemObject["Content"], itemObject["IsNew"].GetBoolean()); if (itemObject.ContainsKey("Docs")) @@ -290,7 +297,7 @@ namespace AppUIBasics.Data foreach (JsonValue docValue in itemObject["Docs"].GetArray()) { JsonObject docObject = docValue.GetObject(); - item.Docs.Add(new ControlInfoDocLink(docObject["Title"].Value(), docObject["Uri"].Value())); + item.Docs.Add(new ControlInfoDocLink(docObject["Title"], docObject["Uri"])); } } @@ -298,7 +305,7 @@ namespace AppUIBasics.Data { foreach (JsonValue relatedControlValue in itemObject["RelatedControls"].GetArray()) { - item.RelatedControls.Add(relatedControlValue.Value()); + item.RelatedControls.Add(relatedControlValue); } } @@ -313,5 +320,5 @@ namespace AppUIBasics.Data } #endif } - } + } } diff --git a/Samples/XamlUIBasics/cs/AppUIBasics.UWP/AppUIBasics.UWP.csproj b/Samples/XamlUIBasics/cs/AppUIBasics.UWP/AppUIBasics.UWP.csproj index 91e4d04f..90f8cac3 100644 --- a/Samples/XamlUIBasics/cs/AppUIBasics.UWP/AppUIBasics.UWP.csproj +++ b/Samples/XamlUIBasics/cs/AppUIBasics.UWP/AppUIBasics.UWP.csproj @@ -108,6 +108,9 @@ + + 4.5.0 + 1.42.0-dev.357 diff --git a/Samples/XamlUIBasics/cs/AppUIBasics.Wasm/AppUIBasics.Wasm.csproj b/Samples/XamlUIBasics/cs/AppUIBasics.Wasm/AppUIBasics.Wasm.csproj index a24fe74c..613ea1e6 100644 --- a/Samples/XamlUIBasics/cs/AppUIBasics.Wasm/AppUIBasics.Wasm.csproj +++ b/Samples/XamlUIBasics/cs/AppUIBasics.Wasm/AppUIBasics.Wasm.csproj @@ -34,7 +34,7 @@ - + diff --git a/Samples/XamlUIBasics/cs/AppUIBasics.iOS/AppUIBasics.iOS.csproj b/Samples/XamlUIBasics/cs/AppUIBasics.iOS/AppUIBasics.iOS.csproj index fe08a66f..fca5ec6e 100644 --- a/Samples/XamlUIBasics/cs/AppUIBasics.iOS/AppUIBasics.iOS.csproj +++ b/Samples/XamlUIBasics/cs/AppUIBasics.iOS/AppUIBasics.iOS.csproj @@ -122,8 +122,8 @@ - - + +