Exemplo n.º 1
0
        public static ReactiveCommand <TOut> SetNewCommand <T, TOut>(this ReactiveCommand <TOut> command, T target,
                                                                     Expression <Func <T, ReactiveCommand <TOut> > > memberLamda)
            where T : class
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            if (memberLamda == null)
            {
                throw new ArgumentNullException(nameof(memberLamda));
            }

            var memberSelectorExpression = memberLamda.Body as MemberExpression;

            if (memberSelectorExpression == null)
            {
                throw new Exception("Not a member expression? " + target);
            }
            var property = memberSelectorExpression.Member as PropertyInfo;

            if (property == null)
            {
                throw new Exception("Not a property? " + target);
            }
            command.DefaultSetup(target.GetCallerName(property));
            property.SetValue(target, command, null);
            return(command);
        }
Exemplo n.º 2
0
        static ReactiveCommand CreateCommand(string name = null)
        {
            var command = new ReactiveCommand();

            command.DefaultSetup(name);
            return(command);
        }
Exemplo n.º 3
0
        public static ReactiveCommand CreateCommand(string name, bool allowMultiple, bool initialCondition = true)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var command = new ReactiveCommand(null, allowMultiple, null, initialCondition);

            command.DefaultSetup(name);
            return(command);
        }
Exemplo n.º 4
0
        static ReactiveCommand CreateCommand(IObservable <bool> ena, string name, bool initialCondition = true)
        {
            if (ena == null)
            {
                throw new ArgumentNullException(nameof(ena));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var command = new ReactiveCommand(ena, initialCondition);

            command.DefaultSetup(name);
            return(command);
        }