Exemplo n.º 1
0
 public void TestAttemptingToSetPropertyOfValueTypeInstance()
 {
     MyStruct myYearHolder = new MyStruct();
     IDynamicProperty year = Create( typeof( MyStruct ).GetProperty( "Year" ) );
     year.SetValue( myYearHolder, 2004 );
 }
Exemplo n.º 2
0
        public void TestInstanceFields()
        {
            IDynamicField name = Create( typeof( Inventor ).GetField( "Name" ) );
            Assert.AreEqual( tesla.Name, name.GetValue( tesla ) );
            name.SetValue( tesla, "Tesla, Nikola" );
            Assert.AreEqual( "Tesla, Nikola", tesla.Name );
            Assert.AreEqual( "Tesla, Nikola", name.GetValue( tesla ) );

            MyStruct myYearHolder = new MyStruct();
            myYearHolder.Year = 2004;
            IDynamicField year = Create( typeof( MyStruct ).GetField( "year", BINDANY ) );
            Assert.AreEqual( 2004, year.GetValue( myYearHolder ) );
        }
Exemplo n.º 3
0
        public void SetValue(object target, object value)
        {
            MyStruct o = (MyStruct)target;

            o.Year = (int)value;
        }
Exemplo n.º 4
0
 public void TestAttemptingToSetFieldOfValueTypeInstance()
 {
     MyStruct myYearHolder = new MyStruct();
     IDynamicField year = Create( typeof( MyStruct ).GetField( "year" ) );
     year.SetValue( myYearHolder, 2004 );
 }
 public void TestAttemptingToSetPropertyOfValueTypeInstance()
 {
     MyStruct myYearHolder = new MyStruct();
     IDynamicProperty year = Create(typeof(MyStruct).GetProperty("Year"));
     Assert.Throws<InvalidOperationException>(() => year.SetValue(myYearHolder, 2004));
 }