intermediate broken
This commit is contained in:
parent
b1fb26db5a
commit
c77ef68e70
@ -21,6 +21,34 @@ public class FleetManager
|
||||
|
||||
public FleetManager() {}
|
||||
|
||||
public class FleetSummary
|
||||
{
|
||||
public string Destination { get; set; } = string.Empty;
|
||||
public int TotalIronium { get; set; }
|
||||
public int TotalBoranium { get; set; }
|
||||
public int TotalGermanium { get; set; }
|
||||
public int TotalColonists { get; set; }
|
||||
}
|
||||
private IObservable<IChangeSet<FleetSummary, string>>? _fleetSummaries;
|
||||
|
||||
public void test()
|
||||
{
|
||||
/*
|
||||
_fleetSummaries = _fleets.Connect()
|
||||
.Group(fleet => fleet.TrueDestination)
|
||||
.Transform(grouping => new FleetSummary
|
||||
{
|
||||
Destination = grouping.Key,
|
||||
TotalIronium = grouping.Items.Sum(f => f.Ironium),
|
||||
TotalBoranium = grouping.Items.Sum(f => f.Boranium),
|
||||
TotalGermanium = grouping.Items.Sum(f => f.Germanium),
|
||||
TotalColonists = grouping.Items.Sum(f => f.Colonists)
|
||||
})
|
||||
.Sort(SortExpressionComparer<FleetSummary>.Ascending(f => f.Planet))
|
||||
.AsObservableChangeSet(summary => summary.Planet);
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the fleet records from the database and push them into our source cache.
|
||||
/// If the data has been freshly imported, call PostProcessImportedData first.
|
||||
@ -29,7 +57,12 @@ public class FleetManager
|
||||
{
|
||||
using var db = Locator.Current.GetService<StarsDatabase>()!;
|
||||
var allFleets = db.Fleet.ToList();
|
||||
_fleets.AddOrUpdate(allFleets);
|
||||
_fleets.Edit(innerCache =>
|
||||
{
|
||||
innerCache.Clear();
|
||||
innerCache.AddOrUpdate(allFleets);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -36,6 +36,15 @@ public class PlanetManager
|
||||
{
|
||||
using var db = Locator.Current.GetService<StarsDatabase>()!;
|
||||
var allPlanets = db.Planet.ToList();
|
||||
_planets.AddOrUpdate(allPlanets);
|
||||
var cacheKeys = _planets.Keys.ToList();
|
||||
var planetNames = from p in allPlanets select p.Name;
|
||||
var planetsToDelete = cacheKeys.Except(planetNames);
|
||||
_planets.Edit(innerCache =>
|
||||
{
|
||||
foreach (var name in planetsToDelete)
|
||||
innerCache.RemoveKey(name);
|
||||
innerCache.AddOrUpdate(allPlanets);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.3" />
|
||||
<PackageReference Include="CsvHelper" Version="33.0.1" />
|
||||
<!-- PackageReference Include="DynamicData" Version="9.0.4" /-->
|
||||
<PackageReference Include="Material.Icons.Avalonia" Version="2.1.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user