//readonly Type[] _targetGenericArgBindings; public static DuckMethodBindingOption TryBind(MethodInfo adaptee, MethodInfo candidate) { var adapteeParams = adaptee.GetParameters(); var candidateParams = candidate.GetParameters(); if (adapteeParams.Length != candidateParams.Length) { return(null); } var retValBinding = DuckValueBindingOption.Get(candidate.ReturnType, adaptee.ReturnType); if (!retValBinding.Bindable) { return(null); } var paramBindings = new List <DuckParamBindingOption>(adapteeParams.Length); for (int i = 0; i < adapteeParams.Length; ++i) { var paramBinding = DuckParamBindingOption.Get(adapteeParams[i], candidateParams[i]); if (!paramBinding.Bindable) { return(null); } paramBindings.Add(paramBinding); } return(new StandardMethodBinding(adaptee, candidate, retValBinding, paramBindings)); }
internal ImplicitNullableValueBinding(bool fromTypeNullable, Type fromType, Type toType, Type coreToType, DuckValueBindingOption coreBinding) { _fromTypeNullable = fromTypeNullable; _fromType = fromType; _toType = toType; _coreToType = coreToType; _coreBinding = coreBinding; }
StandardMethodBinding(MethodInfo adaptee, MethodInfo target, DuckValueBindingOption retValBinding, List<DuckParamBindingOption> paramBindings) { _adaptee = adaptee; _target = target; _retValBinding = retValBinding; _paramBindings = paramBindings; _score = _retValBinding.Score + _paramBindings.Sum(a => a.Score); //_targetGenericArgBindings = new Type[target.GetGenericArguments().Length]; }
StandardMethodBinding(MethodInfo adaptee, MethodInfo target, DuckValueBindingOption retValBinding, List <DuckParamBindingOption> paramBindings) { _adaptee = adaptee; _target = target; _retValBinding = retValBinding; _paramBindings = paramBindings; _score = _retValBinding.Score + _paramBindings.Sum(a => a.Score); //_targetGenericArgBindings = new Type[target.GetGenericArguments().Length]; }
public static DuckParamBindingOption TryBind(ParameterInfo fromParam, ParameterInfo toParam) { if (fromParam.IsOut != toParam.IsOut || fromParam.IsRetval != toParam.IsRetval) { return(null); } var valueBinding = DuckValueBindingOption.Get(fromParam.ParameterType, toParam.ParameterType); return(valueBinding.Bindable ? new InParamBinding(valueBinding) : null); }
public static DuckParamBindingOption TryBind(ParameterInfo fromParam, ParameterInfo toParam) { if (!fromParam.IsOut || !toParam.IsOut) { return(null); } var toType = toParam.ParameterType.GetElementType(); var fromType = fromParam.ParameterType.GetElementType(); var valueBinding = DuckValueBindingOption.Get(toType, fromType); return(valueBinding.Bindable ? new OutParamBinding(valueBinding, fromType, toType) : null); }
public InParamBinding(DuckValueBindingOption valueBinding) { _valueBinding = valueBinding; }
public OutParamBinding(DuckValueBindingOption valueBinding, Type fromType, Type toType) { _valueBinding = valueBinding; _fromType = fromType; _toType = toType; }