Inheritance: Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourceBinding, ICommand
Ejemplo n.º 1
0
        public bool TryCreateBinding(object source, MvxPropertyToken currentToken, List <MvxPropertyToken> remainingTokens, out IMvxSourceBinding result)
        {
            if (source == null)
            {
                result = null;
                return(false);
            }

            if (remainingTokens.Count > 0)
            {
                result = null;
                return(false);
            }

            var propertyNameToken = currentToken as MvxPropertyNamePropertyToken;

            if (propertyNameToken == null)
            {
                result = null;
                return(false);
            }

            var methodInfo = FindMethodInfo(source, propertyNameToken.PropertyName);

            if (methodInfo == null)
            {
                result = null;
                return(false);
            }

            var parameters = methodInfo.GetParameters();

            if (parameters.Count(p => !p.IsOptional) > 1)
            {
                MvxBindingTrace.Warning("Problem binding to Method {0} - too many non-optional parameters");
            }

            result = new MvxMethodSourceBinding(source, methodInfo);
            return(true);
        }
        public bool TryCreateBinding(object source, MvxPropertyToken currentToken, List<MvxPropertyToken> remainingTokens, out IMvxSourceBinding result)
        {
            if (source == null)
            {
                result = null;
                return false;
            }

            if (remainingTokens.Count > 0)
            {
                result = null;
                return false;
            }

            var propertyNameToken = currentToken as MvxPropertyNamePropertyToken;
            if (propertyNameToken == null)
            {
                result = null;
                return false;
            }

            var methodInfo = FindMethodInfo(source, propertyNameToken.PropertyName);

            if (methodInfo == null)
            {
                result = null;
                return false;
            }

            var parameters = methodInfo.GetParameters();
            if (parameters.Count(p => !p.IsOptional) > 1)
            {
                MvxBindingTrace.Warning("Problem binding to Method {0} - too many non-optional parameters");
            }

            result = new MvxMethodSourceBinding(source, methodInfo);
            return true;
        }