c# - How to get unique key for any method invocation? -


i need generate 'hash' unique method invocation in project. example, have method string getsomestring(int someint). so, need different hashes in cases:

string getsomestring(1) -- key 1 string getsomestring(2) -- key 2 string getsomestring(3) -- key 3 

how generate kind of hashes?

upd: want log method execution unique hash each method invocation. this:

public delegate t helperfactorymethod<t>();  public static logmethodexecution<t>(helperfactorymethod<t> factorymethod) t: class {    string key = gethashstring(factorymethod);    storetodatabase(key);    ... } 

result example of gethashstring() must :

  1. list getsomeobjects(1, objecttype.simple) must 'listgetsomeobjects_1_objecttype.simple' or this.
  2. list getsomeobjects(2, objecttype.none) must 'listgetsomeobjects_2_objecttype.none' or this.

you use hash function generete unique key parameter values. example:

public string getsomestring(int someint) {     md5cryptoserviceprovider cryptoserviceprovider = new md5cryptoserviceprovider();     byte[] data = encoding.ascii.getbytes(string.format("{0}{1}", "methodname", someint));     data = cryptoserviceprovider.computehash(data);     return convert.tostring(data); } 

every unique 'methodname' , parameter return unique key


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -