示例#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);
             };
         }
     }
 }
 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()));
 }