Accessing Private Fields from Outside

Jacob Carlborg doob at me.com
Wed May 18 02:30:33 PDT 2011


On 2011-05-18 01:47, Mehrdad wrote:
> Is there any (hacky) way of accessing a private field from outside a
> data type? (The equivalent of reflection in managed languages.)
>
> I'm trying to write a piece of marshaling code that needs access to a
> data type's fields, but can't access them because it's not allowed to. :(

You can have a look at my serialization library, Orange: 
http://www.dsource.org/projects/orange

I don't think it works with the latest compilers but you have have a 
look at the source: 
http://www.dsource.org/projects/orange/browser/orange/util/Reflection.d#L277

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list