I am writing an RPC engine and I am using reflection to call the method by its string name. I want to improve performance and thought of somehow using a Hashtable, so I can call the method with Hashtablemethodname, since methodInfo.Invoke's performance isn't that good. My idea was to use delegates, at first I tried using a Dictionary ( the keys are all the same type ) but the values have different types, since in general the parameters are different in number and type.
At least a Hashtable let's you insert all kinds of types ( probably also not the best way performancewise, but I can't use a dictionary... ). I somehow have to store the method as a value, so I thought of delegates. I can create delegates with the Delegate.CreateDelegate or MethodInfo.CreateDelegate function, but they require a type as a parameter and I don't have anything to put in there?
Got any ideas?
Aucun commentaire:
Enregistrer un commentaire