static void Main(string[] args) { CustomList c = new CustomList(); dynamic d = c.AsDynamic(); object a; try { a = d.Invoke; } catch (Exception ex) { Console.WriteLine(ex.Message); } var newDataField = new DataField() { Name = "Invoke", Value = 1000 }; c.Add(newDataField); a = d.Invoke; c.Remove(newDataField); try { a = d.SomeProperty; } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine(a); }
public void CustomListProperyToDynamicList() { var list = new CustomList <string>() { "a", "b" }; var dynamicList = list.AsDynamic(); Assert.AreEqual("a", dynamicList.First()); Assert.AreEqual("b", dynamicList.Last()); }