On 8/30/11 12:41 PM, jdrewsen wrote:
Couldn't this be used for marking classes as serializable. Something
like this:

class Foo {

@custom("serialize") Cake theCake;
Bar cache;
}

SerializeCustom!("serialize", Foo);

template SerializeCustom(string attribute, alias cls) {
foreach (m; __traits(listMembers, cls)) {
static if ( __traits(hasCustomAttribute(attribute, m) ) {
Serializer.register(cls, m);
}

}
}

----------

Though I would prefer if you could just write:
@custom("serialize") class Foo { ... }

instead of:
SerializeCustom!("serialize", Foo);

I think a convention based on the name of the field shouldn't be half bad.

Andrei

Reply via email to