diff --git a/Maui.DataGrid.Sample/Utils/DummyDataProvider.cs b/Maui.DataGrid.Sample/Utils/DummyDataProvider.cs index 367877e..2857615 100644 --- a/Maui.DataGrid.Sample/Utils/DummyDataProvider.cs +++ b/Maui.DataGrid.Sample/Utils/DummyDataProvider.cs @@ -12,16 +12,19 @@ internal static class DummyDataProvider public static List GetTeams(int numberOfCopies = 1) { - var assembly = typeof(DummyDataProvider).GetTypeInfo().Assembly; + if (_realTeams == null) + { + var assembly = typeof(DummyDataProvider).GetTypeInfo().Assembly; - using var stream = assembly.GetManifestResourceStream("Maui.DataGrid.Sample.teams.json") - ?? throw new FileNotFoundException("Could not load teams.json"); + using var stream = assembly.GetManifestResourceStream("Maui.DataGrid.Sample.teams.json") + ?? throw new FileNotFoundException("Could not load teams.json"); - using var reader = new StreamReader(stream); - var json = reader.ReadToEnd(); + using var reader = new StreamReader(stream); + var json = reader.ReadToEnd(); - _realTeams = JsonSerializer.Deserialize>(json) - ?? throw new InvalidOperationException("Could not deserialize teams.json"); + _realTeams = JsonSerializer.Deserialize>(json) + ?? throw new InvalidOperationException("Could not deserialize teams.json"); + } if (numberOfCopies == 1) { @@ -36,10 +39,10 @@ public static List GetTeams(int numberOfCopies = 1) { var randomTeam = new Team { - Name = $"{realTeam.Name} {RandomNumber.Next(1, numberOfCopies)}", + Name = $"{realTeam.Name} {i}", Won = RandomNumber.Next(0, 50), Lost = RandomNumber.Next(0, 50), - Percentage = RandomNumber.NextDouble(), + Percentage = Math.Round(RandomNumber.NextDouble() * 100) / 100, Conf = $"{realTeam.Conf} {RandomNumber.Next(1, 10)}", Div = $"{realTeam.Div} {RandomNumber.Next(1, 10)}", Home = $"{RandomNumber.Next(1, 10)}",