Hi everyone
Trying to store data settings, I am experiencing some problems. I think it is more C# trouble that GHI related stuff but anyway here is what I want to do:
Settings in my application is a set of data (a class that I called DATASET) stored as an hashtable(key,dataset_element).
My class is:
[Serializable]
class DATASET
{
public static Hashtable datatable = new Hashtable();
public DATASET()
{
//datatable = new Hashtable();
}
public void add_data(int key,DataSetEl my_object)
{
datatable.Add(key,my_object);
}
public void show_all_table()
{
foreach(DictionaryEntry de in datatable)
{
Debug.Print("Key=" + de.Key + "\t Value=" + de.Value.ToString());
}
}
}
and here is the class for DataSetElement:
[Serializable]
class DataSetEl
{
string Var;
string Name;
string Source;
string Param1;
string Param2;
string Param3;
string offset;
string amortissement;
int nb_decimale;
bool sign; //0=negatif, 1 positif
int nb_digit;
//constructeur par défaut
public DataSetEl(string my_var,string my_name,string my_source,string my_Param1,string my_Param2,string my_Param3,string my_offset,string my_amortissement,int my_nb_dec,bool my_sign,int my_nb_digit)
{
Var = my_var;
Name = my_name;
Source = my_source;
Param1 = my_Param1;
Param2 = my_Param2;
Param3 = my_Param3;
offset = my_offset;
amortissement = my_amortissement;
nb_decimale = my_nb_dec;
sign = my_sign;
nb_digit = my_nb_digit;
}
public override string ToString()
{
return (Var+"\t"+Name+"\t"+Source+"\t"+Param1+"\t"+Param2+"\t"+Param3+"\t"+offset+"\t"+amortissement+"\t"+nb_decimale+"\t"+sign+"\t"+nb_digit);
}
}
my main function runs:
settingsReference= ExtendedWeakReference.RecoverOrCreate(typeof(DATASET),0,ExtendedWeakReference.c_SurvivePowerdown);
// If the entry was just created, its value is intitated with Touche1
if(settingsReference.Target == null)
{
Datasets = new DATASET();
DataSetEl afirstdatasetel = new DataSetEl("Touche1","Key1","System","Touche","","","0","",5,false,5);
Datasets.add_data(1,afirstdatasetel);
}
else
{
Datasets = (DATASET) settingsReference.Target;
}
Datasets.show_all_table();
settingsReference.Target =Datasets;
GHIElectronics.NETMF.System.Util.FlushExtendedWeakReferences();
On the first run data are properly printed out, which seems that Datasets is properly initialized.
On the second run, I am expecting the same print out but nothing append and the hashtable is empty (_count=0)
Do you have any idea about how to solve this (EWR + hashtable(key,object)) ?