コード例 #1
0
 public void can_create_new_bag_with_list()
 {
     dynamic lb = new ListBag();
     lb <<= new {Name = "John", Email="email"};
     Assert.That(lb.Name, Is.EqualTo("John"));
     Assert.That(lb.Email, Is.EqualTo("email"));
 }
コード例 #2
0
ファイル: ListBag.cs プロジェクト: jcteague/dynamic-demo
 public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result)
 {
     if(binder.Operation == ExpressionType.LeftShiftAssign)
     {
         var copy = new ListBag(_dict, _list);
         copy.AddMembersFromObject(arg);
         result = copy;
         return true;
     }
     result = null;
     return false;
 }
コード例 #3
0
 public void can_get_by_index()
 {
     dynamic lb = new ListBag();
     lb.Name = "John";
     Assert.That(lb[0], Is.EqualTo("John"));
 }
コード例 #4
0
 public void can_get_and_set_by_name()
 {
     dynamic lb = new ListBag();
     lb.Name = "John";
     Assert.AreEqual(lb.Name,"John");
 }