Example #1
0
        [Test] public void StaticMethodWithParmsIsInvoked()
        {
            RuntimeMember method = new RuntimeType(instance.GetType()).FindStatic(new IdentifierName("parse"), new [] { typeof(string) });

            Assert.IsNotNull(method);
            TypedValue result = method.Invoke(new object[] { "input" });

            Assert.AreEqual(typeof(SampleClass), result.Type);
        }
Example #2
0
 [Test] public void StaticMethodWithParmsIsInvoked()
 {
     foreach (var method in new RuntimeType(instance.GetType()).FindStatic(MemberName.ParseMethod, new [] { typeof(string) }).Value)
     {
         TypedValue result = method.Invoke(new object[] { "input" });
         Assert.AreEqual(typeof(SampleClass), result.Type);
         return;
     }
     Assert.Fail("no method");
 }
Example #3
0
 public static void TestMethod()
 {
     var internalType =
         typeof(Array).GetNestedType(
             "ArrayEnumerator", BindingFlags.NonPublic);
     var x               = new SampleClass();
     var type            = x.GetType();
     var bindingAttr     = BindingFlags.Instance | BindingFlags.NonPublic;
     var info            = type.GetField("dict", bindingAttr);
     var dict            = info.GetValue(x) as IDictionary <Type, object>;
     var arrayEnumerator = dict[internalType];
 }
Example #4
0
    public static void Main()
    {
        var listValue = new List <string>()
        {
            "Hello",
            "Hello2",
            "Hello3",
        };

        var sampleClass = new SampleClass();
        var sampleType  = sampleClass.GetType();
        var properties  = sampleType.GetProperties().OrderBy(prop => prop.Name).ToList();

        for (int i = 0; i < listValue.Count; i++)
        {
            if (i < properties.Count)
            {
                properties[i].SetValue(sampleClass, listValue[i]);
                Console.WriteLine(properties[i].Name + " = " + listValue[i]);
            }
        }
        Console.ReadLine();
    }