property.monkey2 772 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Namespace test
  2. #Import "<reflection>"
  3. #Reflect test
  4. Using reflection..
  5. Using std..
  6. Class C
  7. Field _name:="Brian"
  8. Field _pos:=New Vec3f( 1,2,3 )
  9. Property Name:String()
  10. Return _name
  11. Setter( name:String )
  12. _name=name
  13. End
  14. End
  15. Class C Extension
  16. Property Position:Vec3f()
  17. Return _pos
  18. Setter( pos:Vec3f )
  19. _pos=pos
  20. End
  21. End
  22. Function Main()
  23. Local c:=New C
  24. Print "Name="+c.Name
  25. 'set name using reflection
  26. SetProperty( "Name",c,"Douglas" )
  27. 'get name using reflection
  28. Print "Name="+GetProperty<String>( "Name",c )
  29. Print "Position="+c.Position
  30. 'set position using reflection
  31. SetProperty( "Position",c,New Vec3f( 4,5,6 ) )
  32. 'set position using reflection
  33. Print "Position="+GetProperty<Vec3f>( "Position",c )
  34. End