/* * Copyright (c), 2009 Sigbjorn Finne * * The HsBinder class is a basic, custom implementation of the * method/field Binder class, guiding method resolution. * */ using System; using System.Runtime.InteropServices; using System.Reflection; using System.Reflection.Emit; using System.Globalization; namespace HsInvoker { // // Class: HsBinder // // See the System.Reflection.Binder type for detailed documentation // of the methods we override here. // [ComVisible(false)] public class HsBinder : Binder { private int[] m_arg_types; private int m_result_ty; public HsBinder(int[] a,int r) { m_arg_types = a; m_result_ty = r; } public override FieldInfo BindToField( BindingFlags bindingAttr, FieldInfo[] match, object val, CultureInfo culture ) { return Type.DefaultBinder.BindToField(bindingAttr,match,val,culture); } public override MethodBase BindToMethod( BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] names, out object state ) { int current_match = 0; // Console.WriteLine("BindToMethod.len: {0}", match.Length); state = null; if (match.Length < 2) { return match[current_match]; } // // Walk through the candidate matches left-to-right, being // guided by the type descriptors for each argument passed // in on 'the other side' // for (int i=0;i