public ReactiveTable() { var type = typeof(T); foreach (var propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(p => p.GetCustomAttribute <CalculatedColumnAttribute>() == null)) { AddColumn(ReactiveColumn.Create($"{type.Name}.{propertyInfo.Name}", propertyInfo.PropertyType)); } var token = Subscribe(update => { if (update.Action == TableUpdateAction.Add) { var item = new T(); item.SetTable(this); item.SetRowIndex(update.RowIndex); ChangeNotifier.RegisterPropertyNotifiedConsumer(item, update.RowIndex); Flyweights.Add(item); } else if (update.Action == TableUpdateAction.Delete) { // TODO: Look at efficiency of this var item = Flyweights[update.RowIndex]; ChangeNotifier.UnregisterPropertyNotifiedConsumer(item, update.RowIndex); Flyweights.RemoveAt(update.RowIndex); } }); }
public FlyweightFactory() { Flyweights.Add("ConcreteFlyweightA", new ConcreteFlyweight()); Flyweights.Add("ConcreteFlyweightB", new ConcreteFlyweight()); Flyweights.Add("ConcreteFlyweightC", new ConcreteFlyweight()); }