Merged in ladder_validation_no_account (pull request #16)
Enforcing account validation at the start in the case a user does not have any accounts from the new AdminService
This commit is contained in:
commit
3d08755ffe
3 files changed
+18
-9
No files matched your search
@@ -50,8 +50,8 @@ namespace mbts.spark {
|
||||
_model = model;
|
||||
accounts = model.factory.accounts;
|
||||
order_types = new ObservableAutoWrapper<IOrderTypeVM, CustomOrderDefinition.CustomOneofCase>(_order_types_model, ot => OrderTypeVMFactory.create(ot, model, security_source));
|
||||
_selected_account = backing(nameof(selected_account), string.Empty, val => val != null && accounts.Contains(val));
|
||||
_selected_time_in_force = backing(nameof(selected_time_in_force), TimeInForce.Undefined, time_in_forces.Contains);
|
||||
_selected_account = backing(nameof(selected_account), string.Empty, true, val => !String.IsNullOrWhiteSpace(val) && accounts.Contains(val));
|
||||
_selected_time_in_force = backing(nameof(selected_time_in_force), TimeInForce.Undefined, false, time_in_forces.Contains);
|
||||
InlineOrderProperties props = new InlineOrderProperties();
|
||||
_dispose = Disposable.Create(
|
||||
security_source.ObserveOnDispatcher().Subscribe(s => {
|
||||
|
||||
@@ -320,17 +320,22 @@ namespace mbts.ui.shell
|
||||
public IEnumerable<string> AllErrors { get { return _errors.Values; } }
|
||||
#endregion
|
||||
|
||||
protected Property<T> backing<T>(string name, T default_value, params Func<T, bool>[] validation_steps) =>
|
||||
backing(name, default_value, validation_steps.Select(v => new PropertyValidation<T>(v)).ToLArray());
|
||||
protected Property<T> backing<T>(string name, T default_value, bool validate_now = false, params Func<T, bool>[] validation_steps) =>
|
||||
backing(name, default_value, validation_steps.Select(v => new PropertyValidation<T>(v)).ToLArray(), validate_now);
|
||||
|
||||
protected Property<T> backing<T>(string name, T default_value, IEnumerable<PropertyValidation<T>> validation_steps) {
|
||||
var prop = new Property<T>(this, name, default_value);
|
||||
prop.Changed += (old_val, new_val) => {
|
||||
protected Property<T> backing<T>(string name, T default_value, IEnumerable<PropertyValidation<T>> validation_steps, bool validate_now = false) {
|
||||
void run_validation(T val) {
|
||||
foreach (var pv in validation_steps) {
|
||||
(bool valid, string msg) = pv.validate(new_val);
|
||||
(bool valid, string msg) = pv.validate(val);
|
||||
assert(valid, name, msg);
|
||||
}
|
||||
};
|
||||
|
||||
var prop = new Property<T>(this, name, default_value);
|
||||
prop.Changed += (old_val, new_val) => run_validation(new_val);
|
||||
if (validate_now) {
|
||||
run_validation(prop.Value);
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,11 @@ namespace mbts.spark.utilities {
|
||||
}
|
||||
|
||||
#region Defaults
|
||||
public string default_account => accounts[0];
|
||||
public string default_account {
|
||||
get {
|
||||
return (!accounts.is_null_or_empty()) ? accounts[0] : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, uint> _account_map;
|
||||
public string[] accounts { get; private set; }
|
||||
|
||||
Reference in new issue
Block a user