OrderBookRowVM doesn't need to derive from DisposableViewModelBase (keep it super light)
This commit is contained in:
1 parent
3aefa57578
commit
ccddf3b1cd
2 files changed
+21
-9
No files matched your search
@@ -4,15 +4,16 @@ using bts.api.orderman;
|
||||
using bts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.shell;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Columns = mbts.spark.OrderBookGridView.ColumnKeys;
|
||||
|
||||
namespace mbts.spark {
|
||||
partial class OrderBookRowVM : DisposableViewModelBase, IEquatable<OrderBookRowVM>, DIYGrid.IRowVM {
|
||||
partial class OrderBookRowVM : IEquatable<OrderBookRowVM>, DIYGrid.IRowVM, INotifyPropertyChanged {
|
||||
const string _unknown_security_price_format_string = "0.#########";
|
||||
const int _unknown_security_price_num_fractional_digits = 9;
|
||||
readonly OrderBookVM _owner;
|
||||
@@ -56,13 +57,9 @@ namespace mbts.spark {
|
||||
cb => invalidated -= cb);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing) {
|
||||
this.invalidated -= OrderBookRowVM_invalidated;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public event Action invalidated;
|
||||
public event Action<(OrderSecurityAlgoMeta oldval, OrderSecurityAlgoMeta newval)> updated;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
// Core
|
||||
public OrderSecurityAlgoMeta order_tuple { get; private set; }
|
||||
@@ -322,6 +319,22 @@ namespace mbts.spark {
|
||||
security.Value.ContractSpec.format(v) :
|
||||
Math.Round(v, _unknown_security_price_num_fractional_digits, MidpointRounding.AwayFromZero).ToString(_unknown_security_price_format_string);
|
||||
|
||||
void RaisePropertyChanged(params string[] props) {
|
||||
var pc = PropertyChanged;
|
||||
if (pc == null)
|
||||
return;
|
||||
for (int i = 0; i < props.Length; i++)
|
||||
pc(this, new PropertyChangedEventArgs(props[i]));
|
||||
}
|
||||
|
||||
bool Set<T>(ref T backing, T newval, [CallerMemberName]string prop = "") where T : struct, IEquatable<T> {
|
||||
if (!backing.Equals(newval)) {
|
||||
backing = newval;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
static class ViewRefresh {
|
||||
public const Columns
|
||||
invalidate_mask =
|
||||
@@ -369,4 +382,4 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,6 @@ namespace mbts.spark {
|
||||
begin_attaching -= on_begin_attaching;
|
||||
end_attaching -= on_end_attaching;
|
||||
Disposable.dispose(ref attach_vm_hooks);
|
||||
Disposable.dispose(_row_collection);
|
||||
}),
|
||||
_columns);
|
||||
if (settings_manager != null) {
|
||||
|
||||
Reference in new issue
Block a user