Пример #1
0
        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;
        }
Пример #2
0
 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);
             };
         }
     }
 }
Пример #3
0
 internal SaberArgumentException(Expression<Func<object>> expression)
     : base("A faulty argument was passed to the Saber Framework.", new ArgumentException(expression.GetPropertyName()))
 {
 }
Пример #4
0
 public RequiredProperty(ValidationHandler validationHandler, Expression<Func<object>> expression)
 {
     _validationHandler = validationHandler;
     _expression = expression.Compile();
     _propertyName = expression.GetPropertyName();
 }
Пример #5
0
 public void SaveState(Expression<Func<object>> property, object value)
 {
     SaveState(property.GetPropertyName(), value);
 }
Пример #6
0
 public object LoadState(Expression<Func<object>> property, object defaultValue = null)
 {
     var key = property.GetPropertyName();
     return LoadState(key, defaultValue);
 }
Пример #7
0
 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()));
 }