I have a singleton that can register a func to resolve an id value for each type:
public void RegisterType<T>(Func<T, uint> func)
for example:
RegisterType<Post>(p => p.PostId );
RegisterType<Comment>(p => p.CommentId );
and then i want to resolve the id for an object, like these:
GetObjectId(myPost);
where GetObjectId definition is
public uint GetObjectId(object obj)
The question is, how can i store a reference for each func to invoke it lately. The problem is that each func has a different T type, and I can't do something like this:
private Dictionary<Type, Func<object, uint>> _typeMap;
How can resolve it? Expression trees?
regards Ezequiel