public ICommand GetOrCreateCommand(Expression<Func<ICommand>> commandPropertyExpression, Action executeAction) { var name = commandPropertyExpression.GetPropertyName(); ICommand command; if (!_commands.TryGetValue(name, out command)) { command = new ActionCommand(_ => executeAction()); _commands.Add(name, command); } return command; }
public DelegateCommand(Action executeMethod, Expression<Func<bool>> canExecuteMethod=null, object commandSource=null) { _executeMethod = executeMethod ?? (() => { }); if (canExecuteMethod == null) _canExecuteMethod = (() => true); else { var propertyName = canExecuteMethod.GetPropertyName(); _canExecuteMethod = canExecuteMethod.Compile(); var notifier = (commandSource??_canExecuteMethod.Target) as INotifyPropertyChanged; if(notifier !=null) { notifier.PropertyChanged += (o, e) => { if (e.PropertyName == propertyName) CanExecuteChanged.Raise(this); }; } } }
internal SaberArgumentException(Expression<Func<object>> expression) : base("A faulty argument was passed to the Saber Framework.", new ArgumentException(expression.GetPropertyName())) { }
public RequiredProperty(ValidationHandler validationHandler, Expression<Func<object>> expression) { _validationHandler = validationHandler; _expression = expression.Compile(); _propertyName = expression.GetPropertyName(); }
public void SaveState(Expression<Func<object>> property, object value) { SaveState(property.GetPropertyName(), value); }
public object LoadState(Expression<Func<object>> property, object defaultValue = null) { var key = property.GetPropertyName(); return LoadState(key, defaultValue); }
public void Clear(Expression<Func<object>> property) { var key = property.GetPropertyName(); Clear(key); }
private void OnPropertyChanged(Expression<Func<RecipeViewModelState, object>> expression) { PropertyChanged(this, new PropertyChangedEventArgs(expression.GetPropertyName())); }