intermediate broken
This commit is contained in:
		@@ -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);
 | 
			
		||||
            }
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user