using ReactiveUI;
using ReactiveUI.SourceGenerators;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reactive.Linq;
using DynamicData;
using DynamicData.Binding;
using PcgsApi;
namespace PcgsInv.Models;
///
/// Contains all information related to a collection of coins.
///
public partial class CoinCollection : ReactiveObject {
///
/// The name of the collection.
///
[Reactive] private string _name;
///
/// The collection of objects.
///
[Reactive] private ObservableCollection _coins;
///
/// The total value of the collection.
///
[ObservableAsProperty] private double _totalValue;
///
/// Creates a new CoinCollection instance.
///
public CoinCollection() {
Name = string.Empty;
Coins = [];
Coins.ToObservableChangeSet()
.AutoRefresh(x => x.TotalPrice)
.ToCollection()
.Select(coins => coins.Sum(c => c.TotalPrice))
.ToProperty(this, nameof(TotalValue), out _totalValueHelper);
}
}