public void SelectAndInvokeAllProperties2 () { Type type = typeof (MultiIndexer); PropertyInfo [] props = type.GetProperties (BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance); Type [] types = { typeof (ushort), typeof (char) }; MultiIndexer obj = new MultiIndexer (); PropertyInfo prop1 = binder.SelectProperty (0, props, null, new Type [] {types [0]}, null); PropertyInfo prop2 = binder.SelectProperty (0, props, null, new Type [] {types [1]}, null); Assert.AreEqual (prop1, prop2); }
public void SelectAndInvokeAllProperties1 () { Type type = typeof (MultiIndexer); PropertyInfo [] props = type.GetProperties (BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance); // These don't cause an AmbiguousMatchException Type [] types = { typeof (byte), typeof (short), typeof (int), typeof (long), typeof (MyEnum) }; /* MS matches short for sbyte!!! */ /* MS matches int for ushort!!! */ /* MS matches long for uint!!! */ /** These do weird things under MS if used together and then in separate arrays * Type [] types = { typeof (ulong), typeof (float), typeof (double), typeof (decimal), typeof (object) }; */ MultiIndexer obj = new MultiIndexer (); foreach (Type t in types) { PropertyInfo prop = null; try { prop = binder.SelectProperty (0, props, null, new Type [] {t}, null); } catch (Exception e) { throw new Exception ("Type: " + t, e); } Type gotten = (Type) prop.GetValue (obj, new object [] {Activator.CreateInstance (t)}); Assert.AreEqual (t, gotten); } }