W
wg
I have written a class to contain tags that are loaded from a spreadsheet. I
can load the value ok. But from another class I would like to change a value
inside the arraylist. Here is my code (see Update).
Thanks
wg
class Singleton
{
private static Singleton instance;
// Lock synchronization object
private static object syncLock = new object();
ArrayList TagList = new ArrayList();
iTags Tags = new iTags();
private Singleton()
{
}
public static Singleton Instance()
{
// Use 'Lazy initialization'
if (instance == null)
{
lock (syncLock)
{
if (instance == null)
{
instance = new Singleton();
}
}
}
return instance;
}
public void Update(int index,int aval, bool bval)
{
((iTags)TagList[index]).ival = aval;
((iTags)TagList[index]).bval = bval;
((Tags)TagList[index]).ival = index;
((iTags)TagList[index]).update = true;
}
public string Name(int index)
{
return ((iTags)TagList[index]).name.ToString();
}
public int i_val(int index)
{
return ((iTags)TagList[index]).ival;
}
public bool b_val(int index)
{
return ((iTags)TagList[index]).bval;
}
public void LoadCSVFile()
{
string BaseDir = AppDomain.CurrentDomain.BaseDirectory +
AppDomain.CurrentDomain.RelativeSearchPath;
string delimStr = ",";
char [] delimiter = delimStr.ToCharArray();
string [] split = new string[4];
char[] splitter = {','};
using (StreamReader sr = new StreamReader(BaseDir + "IntTags.csv"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
split = line.Split(splitter);
Tags.folder = split[0];
Tags.name = split[1];
Tags.type = split[2];
TagList.Add(Tags);
}
}
}
}
class iTags
{
public string folder;
public string name;
public string type;
public int ival;
public bool bval;
public bool update;
}
}
can load the value ok. But from another class I would like to change a value
inside the arraylist. Here is my code (see Update).
Thanks
wg
class Singleton
{
private static Singleton instance;
// Lock synchronization object
private static object syncLock = new object();
ArrayList TagList = new ArrayList();
iTags Tags = new iTags();
private Singleton()
{
}
public static Singleton Instance()
{
// Use 'Lazy initialization'
if (instance == null)
{
lock (syncLock)
{
if (instance == null)
{
instance = new Singleton();
}
}
}
return instance;
}
public void Update(int index,int aval, bool bval)
{
((iTags)TagList[index]).ival = aval;
((iTags)TagList[index]).bval = bval;
((Tags)TagList[index]).ival = index;
((iTags)TagList[index]).update = true;
}
public string Name(int index)
{
return ((iTags)TagList[index]).name.ToString();
}
public int i_val(int index)
{
return ((iTags)TagList[index]).ival;
}
public bool b_val(int index)
{
return ((iTags)TagList[index]).bval;
}
public void LoadCSVFile()
{
string BaseDir = AppDomain.CurrentDomain.BaseDirectory +
AppDomain.CurrentDomain.RelativeSearchPath;
string delimStr = ",";
char [] delimiter = delimStr.ToCharArray();
string [] split = new string[4];
char[] splitter = {','};
using (StreamReader sr = new StreamReader(BaseDir + "IntTags.csv"))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
split = line.Split(splitter);
Tags.folder = split[0];
Tags.name = split[1];
Tags.type = split[2];
TagList.Add(Tags);
}
}
}
}
class iTags
{
public string folder;
public string name;
public string type;
public int ival;
public bool bval;
public bool update;
}
}