AlgoDefinitionVM - remove unused 'security_md_source' prop
This commit is contained in:
1 parent
7c7f4fc58f
commit
fab3a69ef9
5 files changed
+13
-15
No files matched your search
@@ -232,7 +232,7 @@ namespace mbts.spark {
|
||||
public class CustomTemplatePlaceholderVM : AlgoDefinitionTemplateVM {
|
||||
const string _custom_name = "(Custom)";
|
||||
|
||||
public CustomTemplatePlaceholderVM(AlgoDefinitionVM owner, OrdersModel model, IObservable<SecurityMD?> security_md_source, CustomOrderDefinitionImmutable definition)
|
||||
public CustomTemplatePlaceholderVM(AlgoDefinitionVM owner, OrdersModel model, CustomOrderDefinitionImmutable definition)
|
||||
: base(owner, model, new AlgoData(definition, _custom_name, new AlgoKey(Guid.NewGuid())), AlgoEditingPermissions.AllowEditStructure | AlgoEditingPermissions.AllowEditValues) {
|
||||
_edit_stack.reset(_snapshot());
|
||||
}
|
||||
|
||||
@@ -53,21 +53,20 @@ namespace mbts.spark {
|
||||
TableUpdateBuffer<AlgoTemplateData, AlgoKey> _template_update_buffer;
|
||||
bool _connected;
|
||||
|
||||
public static AlgoDefinitionVM create(OrdersModel model, AlgoData data, IObservable<SecurityMD?> security_md_source, bool connect = false, AlgoFormats init_format = AlgoFormats.Exchange) {
|
||||
var rv = new AlgoDefinitionVM(model, data, security_md_source, init_format);
|
||||
public static AlgoDefinitionVM create(OrdersModel model, AlgoData data, bool connect = false, AlgoFormats init_format = AlgoFormats.Exchange) {
|
||||
var rv = new AlgoDefinitionVM(model, data, init_format);
|
||||
if (connect)
|
||||
rv.connect();
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static AlgoDefinitionVM create_placeholder(OrdersModel model, CustomOrderDefinitionImmutable def, IObservable<SecurityMD?> security_md_source, string name = new_algo_name) =>
|
||||
new AlgoDefinitionVM(model, new AlgoData(def, name, new AlgoKey(Guid.NewGuid())), security_md_source);
|
||||
public static AlgoDefinitionVM create_placeholder(OrdersModel model, CustomOrderDefinitionImmutable def, string name = new_algo_name) =>
|
||||
new AlgoDefinitionVM(model, new AlgoData(def, name, new AlgoKey(Guid.NewGuid())));
|
||||
|
||||
AlgoDefinitionVM(OrdersModel model, AlgoData def_data, IObservable<SecurityMD?> security_md_source, AlgoFormats init_format = AlgoFormats.Exchange) {
|
||||
AlgoDefinitionVM(OrdersModel model, AlgoData def_data, AlgoFormats init_format = AlgoFormats.Exchange) {
|
||||
// init core data
|
||||
_model = model;
|
||||
key = def_data.key;
|
||||
this.security_md_source = security_md_source ?? Observable.Return<SecurityMD?>(null);
|
||||
_template_update_buffer = new TableUpdateBuffer<AlgoTemplateData, AlgoKey>(t => t.key);
|
||||
_templates_with_custom = new ObservableAppendCollection<AlgoDefinitionTemplateVM>(templates);
|
||||
templates_view = (ListCollectionView)CollectionViewSource.GetDefaultView(_templates_with_custom);
|
||||
@@ -222,7 +221,6 @@ namespace mbts.spark {
|
||||
/// Some users might consider this a regression. The custom-placeholder-item addresses that concern.
|
||||
public ObservableAppendCollection<AlgoDefinitionTemplateVM> templates_with_custom => _templates_with_custom;
|
||||
public ListCollectionView templates_view { get; }
|
||||
public IObservable<SecurityMD?> security_md_source { get; }
|
||||
// format
|
||||
public AlgoFormats selected_format { get => _selected_format.Value; set => _selected_format.set(value); }
|
||||
public ObservableCollection<AlgoFormats> formats { get; } = new ObservableCollection<AlgoFormats> { AlgoFormats.Exchange, AlgoFormats.Spreader, AlgoFormats.Exchange | AlgoFormats.Spreader };
|
||||
@@ -267,7 +265,7 @@ namespace mbts.spark {
|
||||
// idempotent
|
||||
public void prepend_custom_template() {
|
||||
if (_templates_with_custom.appended_front.Count == 0)
|
||||
_templates_with_custom.insert_front(new AlgoDefinitionTemplateVM.CustomTemplatePlaceholderVM(this, _model, security_md_source, algo_root.definition));
|
||||
_templates_with_custom.insert_front(new AlgoDefinitionTemplateVM.CustomTemplatePlaceholderVM(this, _model, algo_root.definition));
|
||||
}
|
||||
|
||||
public AlgoDefinitionTemplateVM template_factory() =>
|
||||
@@ -313,7 +311,7 @@ namespace mbts.spark {
|
||||
|
||||
// pass a copy of the persisted state - rather than use local values - because if something goes wrong, it is better to be in sync with data fresh from the server/api.
|
||||
public AlgoDefinitionVM to_persisted(AlgoData def) =>
|
||||
new AlgoDefinitionVM(_model, def, security_md_source);
|
||||
new AlgoDefinitionVM(_model, def);
|
||||
|
||||
public AlgoData create_algo_def() =>
|
||||
new AlgoData(algo_root.definition, name, key);
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace mbts.spark {
|
||||
//
|
||||
_dispose = new CompositeDisposable(
|
||||
_model.algo_model.definitions.Subscribe(_definitions_update_buffer),
|
||||
_definitions_update_buffer.OnDispatcher().Subscribe(u => AlgoDefinitionVMCollectionHelper.update_persisted_definitions(_definitions, u, d => AlgoDefinitionVM.create(model, d, Observable.Return<SecurityMD?>(null), true))),
|
||||
_definitions_update_buffer.OnDispatcher().Subscribe(u => AlgoDefinitionVMCollectionHelper.update_persisted_definitions(_definitions, u, d => AlgoDefinitionVM.create(model, d, true))),
|
||||
_model.algo_model.metadata_service.subscribe_metadata().OnDispatcher().Subscribe(meta => {
|
||||
_persisted_meta = meta;
|
||||
definitions_view.Refresh();
|
||||
@@ -144,7 +144,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
void _add_new_definition(CustomOrderDefinitionImmutable def, string name) =>
|
||||
_definitions.Add(AlgoDefinitionVM.create_placeholder(_model, def, Observable.Return<SecurityMD?>(null), name));
|
||||
_definitions.Add(AlgoDefinitionVM.create_placeholder(_model, def, name));
|
||||
|
||||
public StartupData create() => new StartupData();
|
||||
public void load_from(StartupData state) { }
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace mbts.spark {
|
||||
security_md_source.Select(smd => model.factory.default_algos(smd.security)).Table(s => s.key).Subscribe(factory_defs => {
|
||||
using (_selected_algo_definition.begin_update())
|
||||
AlgoDefinitionVMCollectionHelper.update_persisted_definitions(_algo_definitions, factory_defs, fd => {
|
||||
var vm = AlgoDefinitionVM.create(_model, fd, nullable_security_md_source, init_format: OrderDataHelper.get_algo_format(security.ContractCase));
|
||||
var vm = AlgoDefinitionVM.create(_model, fd, init_format: OrderDataHelper.get_algo_format(security.ContractCase));
|
||||
vm.selected_format = OrderDataHelper.get_algo_format(security.ContractCase);
|
||||
return vm;
|
||||
});
|
||||
@@ -187,7 +187,7 @@ namespace mbts.spark {
|
||||
model.algo_model.definitions.Subscribe(_definitions_buffer),
|
||||
_definitions_buffer.OnDispatcher().Subscribe(u => {
|
||||
AlgoDefinitionVMCollectionHelper.update_persisted_definitions(_algo_definitions, u, def_data => {
|
||||
var def_vm = AlgoDefinitionVM.create(model, def_data, nullable_security_md_source, true, OrderDataHelper.get_algo_format(security.ContractCase));
|
||||
var def_vm = AlgoDefinitionVM.create(model, def_data, true, OrderDataHelper.get_algo_format(security.ContractCase));
|
||||
def_vm.selected_format = OrderDataHelper.get_algo_format(security.ContractCase);
|
||||
def_vm.favorite_index = _get_favorite_algo_index(def_vm.key);
|
||||
return def_vm;
|
||||
|
||||
@@ -508,7 +508,7 @@ namespace mbts.spark {
|
||||
add_item_cmd = new DelegateCommand(() => _raw_items.Add(_item_factory()));
|
||||
remove_item_cmd = new DelegateCommand<FavoriteAlgoItem>(fai => _raw_items.Remove(fai));
|
||||
_dispose = model.algo_model.definitions.OnDispatcher().Subscribe(update => {
|
||||
AlgoDefinitionVMCollectionHelper.update_persisted_definitions(_algo_definitions, update, d => AlgoDefinitionVM.create(model, d, Observable.Return<SecurityMD?>(null), false));
|
||||
AlgoDefinitionVMCollectionHelper.update_persisted_definitions(_algo_definitions, update, d => AlgoDefinitionVM.create(model, d, false));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user