public static IEnumerable <SalesBinderInventoryItem> RetrieveAndSaveInventory(bool topup_) => retrieveAndSave(() => { var current = Inventory; if (!topup_ || !current.Any()) { return(RetrieveInventory()); } var lastUpdate = new FileInfo(InventoryFilePath).LastWriteTimeUtc; var topup = RetrieveInventory(lastUpdate.AddDays(-1d)); if (!topup.Any()) { return(current); } var currentD = current.ToDictionary(x => x.Id, x => x); topup.ForEach(x => currentD[x.Id] = x); return(currentD.Values); }, InventoryFilePath);
public void TouchXamlFile([Values(false, true)] bool sdkStyle) { if (sdkStyle) { Assert.Ignore("This test fails on sdk style projects"); } var project = NewProject(sdkStyle); project.Add(AddFile("MainPage.xaml", "EmbeddedResource", Xaml.MainPage)); project.Add(AddFile("CustomView.xaml", "EmbeddedResource", Xaml.CustomView)); var projectFile = IOPath.Combine(tempDirectory, "test.csproj"); project.Save(projectFile); RestoreIfNeeded(projectFile, sdkStyle); Build(projectFile); var mainPageXamlG = IOPath.Combine(intermediateDirectory, "MainPage.xaml.g.cs"); var customViewXamlG = IOPath.Combine(intermediateDirectory, "CustomView.xaml.g.cs"); var xamlCStamp = IOPath.Combine(intermediateDirectory, "XamlC.stamp"); AssertExists(mainPageXamlG, nonEmpty: true); AssertExists(customViewXamlG, nonEmpty: true); AssertExists(xamlCStamp); var expectedMainPageXamlG = new FileInfo(mainPageXamlG).LastWriteTimeUtc; var expectedCustomViewXamlG = new FileInfo(customViewXamlG).LastWriteTimeUtc; var expectedXamlC = new FileInfo(xamlCStamp).LastWriteTimeUtc; //Build again, after modifying the timestamp on a Xaml file, should trigger a partial XamlG and full XamlC //https://github.com/xamarin/xamarin-android/blob/61851599fb1999964bd200ec1c373b6e395933f3/src/Microsoft.Maui.Controls.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs#L342 File.SetLastWriteTimeUtc(customViewXamlG, expectedCustomViewXamlG.AddDays(1)); File.SetLastAccessTimeUtc(customViewXamlG, expectedCustomViewXamlG.AddDays(1)); Build(projectFile); AssertExists(mainPageXamlG, nonEmpty: true); AssertExists(customViewXamlG, nonEmpty: true); AssertExists(xamlCStamp); var actualMainPageXamlG = new FileInfo(mainPageXamlG).LastWriteTimeUtc; var actualCustomViewXamlG = new FileInfo(customViewXamlG).LastAccessTimeUtc; var actualXamlC = new FileInfo(xamlCStamp).LastWriteTimeUtc; Assert.AreEqual(expectedMainPageXamlG, actualMainPageXamlG, $"Timestamps should match for {mainPageXamlG}."); Assert.AreNotEqual(expectedMainPageXamlG, actualCustomViewXamlG, $"Timestamps should *not* match for {actualCustomViewXamlG}."); Assert.AreNotEqual(expectedXamlC, actualXamlC, $"Timestamps should *not* match for {xamlCStamp}."); }
public static void RetrieveAndSaveInvoices(bool topup_) => retrieveAndSave(() => { var current = Invoices; if (!topup_ || !current.Any()) { return(RetrieveInvoices()); } var lastUpdate = new FileInfo(InvoicesFilePath).LastWriteTimeUtc; var topup = RetrieveInvoices(lastUpdate.AddDays(-1d)); if (!topup.Any()) { return(current); } var currentD = current.ToDictionary(x => x.Id, x => x); topup.ForEach(x => currentD[x.Id] = x); return(currentD.Values); }, InvoicesFilePath);