digitalmars.D.learn - Implement Interface "dynamically"
- Frustrated (11/11) Jul 14 2014 Is there a way to take an interface and implement it generically?
- Gary Willoughby (3/15) Jul 14 2014 You can maybe get some ideas from this mocking code i wrote:
- Gary Willoughby (2/2) Jul 14 2014 There's some handy refection stuff in there too:
- Dicebot (4/4) Jul 14 2014 http://dlang.org/phobos/std_typecons.html#.BlackHole
Is there a way to take an interface and implement it generically? e.g., All functions are implemented either as throw and/or return defaults and properties are implemented as getter/setters. This is for mocking up so I a simple way to create a class based off only the interface. Essentially something similar to whitehole and blackhole except properties are useable. In fact, I suppose it would be nice to have something analogous to them except properties are implemented. Then one could do Blackhole!(Bluehole!C) where Bluehole implements properties as getters and setters.
Jul 14 2014
On Monday, 14 July 2014 at 14:45:01 UTC, Frustrated wrote:Is there a way to take an interface and implement it generically? e.g., All functions are implemented either as throw and/or return defaults and properties are implemented as getter/setters. This is for mocking up so I a simple way to create a class based off only the interface. Essentially something similar to whitehole and blackhole except properties are useable. In fact, I suppose it would be nice to have something analogous to them except properties are implemented. Then one could do Blackhole!(Bluehole!C) where Bluehole implements properties as getters and setters.You can maybe get some ideas from this mocking code i wrote: https://github.com/nomad-software/dunit/blob/master/source/dunit/mockable.d
Jul 14 2014
There's some handy refection stuff in there too: https://github.com/nomad-software/dunit/blob/master/source/dunit/reflection.d
Jul 14 2014