[Compact framework] Stockage style registry
Bonsoir,
Comment réaliser une class de stockage pour les différentes variables et objet. J'ai tenté un truc comme ca mais ca marche pas bien. car Data peut être de tout type : objet, string, int .... et j'ai l'impression qu'il apprécie pas.
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
class MyRegistry
{
public static Hashtable store = new Hashtable();
public static object get(string key){
return MyRegistry.store[key];
}
public static void set(string key, object data)
{
MyRegistry.store.Add(key, data);
}
} |
En gros j'aimerais pouvoir faire de n'importe ou
Code:
1 2 3 4 5 6 7 8 9
|
MyRegistry.set('toto','tatat');
MyRegistry.set('tata',objetmachinchose);
MyRegistry.set('titit',collection);
MyRegistry.set('tete',111112);
../....
MyRegistry.get('toto')
MyRegistry.get('tata')
../... |
Merci d'avance pour votre aide.