Tuesday, May 14, 2013

Trying to figure out what a System.Reflection.Binder does?

Then try MyBinder.Value and set breakpoints on its methods.
public class MyBinder : Binder
{
 public static readonly MyBinder Value = new MyBinder();
 public override FieldInfo BindToField(BindingFlags bindingAttr, FieldInfo[] match, object value, System.Globalization.CultureInfo culture)
 {
  return Type.DefaultBinder.BindToField(bindingAttr, match, value, culture);
 }
 public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, string[] names, out object state)
 {
  return Type.DefaultBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state);
 }
 public override object ChangeType(object value, Type type, System.Globalization.CultureInfo culture)
 {
  return Type.DefaultBinder.ChangeType(value, type, culture);
 }
 public override void ReorderArgumentArray(ref object[] args, object state)
 {
  Type.DefaultBinder.ReorderArgumentArray(ref args, state);
 }
 public override MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
 {
  return Type.DefaultBinder.SelectMethod(bindingAttr, match, types, modifiers);
 }
 public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers)
 {
  return Type.DefaultBinder.SelectProperty(bindingAttr, match, returnType, indexes, modifiers);
 }
}

0 Comments:

Post a Comment

<< Home