예제 #1
0
        /// <summary>
        /// Gets the <see cref="ImpromptuInterface.MVVM.ImpromptuRelayCommand"/> with the specified key.
        /// </summary>
        /// <value></value>
        public ImpromptuRelayCommand this[String key]
        {
            get
            {
                ImpromptuRelayCommand result;

                if (!_commands.TryGetValue(key, out result))
                {
                    var tCanExecute = string.Format("Can{0}", key);

                    var tDictParent = _parent as IDictionary <string, object>;
                    if ((tDictParent != null && tDictParent.ContainsKey(tCanExecute)) ||
                        _parent.GetType().GetMethod(tCanExecute) != null)
                    {
                        result = new ImpromptuRelayCommand(_parent, key, _parent, tCanExecute, _setup);
                    }
                    else
                    {
                        result = new ImpromptuRelayCommand(_parent, key, _setup);
                    }
                    _commands[key] = result;
                }
                return(result);
            }
        }
        /// <summary>
        /// Gets the <see cref="ImpromptuInterface.MVVM.ImpromptuRelayCommand"/> with the specified key.
        /// </summary>
        /// <value></value>
        public ImpromptuRelayCommand this[String key]
        {
            get
            {
                ImpromptuRelayCommand result;

                if (!_commands.TryGetValue(key, out result))
                {

                    var tCanExecute = string.Format("Can{0}", key);

                    var tDictParent = _parent as IDictionary<string, object>;
                    if ((tDictParent != null && tDictParent.ContainsKey(tCanExecute))
                        || _parent.GetType().GetMethod(tCanExecute) != null)
                    {
                        result = new ImpromptuRelayCommand(_parent, key, _parent, tCanExecute,_setup);
                    }
                    else
                    {
                        result = new ImpromptuRelayCommand(_parent, key,_setup);
                    }
                    _commands[key] = result;
                }
                return result;
            }
        }