I'm finding myself doing this a lot:
(<any>tree.lookup('mynamespace.MyMessage')).encode...
The reason is that lookup returns a ReflectionObject which I cannot directly cast to any of its children (I can cast a Type -> ReflectionObject but not the other way around).
I'm proposing doing something like:
tree.lookupService('mynamespace.MyService'); // ok -> ProtoBuf.Service
tree.lookupType('mynamespace.MyService'); // throws -> MyService is not a Type
Strongly typed with exceptions if you attempt to lookup the wrong type (or just return null)
I'm finding myself doing this a lot:
The reason is that
lookupreturns aReflectionObjectwhich I cannot directly cast to any of its children (I can cast a Type -> ReflectionObject but not the other way around).I'm proposing doing something like:
Strongly typed with exceptions if you attempt to lookup the wrong type (or just return null)