Hello!
I am trying to find a way to deal with Windows' case insensitivity
without just forcing everything lowercase. While I am open to criticism
on my method - my question relates to the fourth to bottom line (not
including curly braces) on the bottom - testing to see if the Comparer
is not StringComparer. OrdinalIgnoreCa se
My concern is eventually when I decide to serialize these to files, to
store persistant data, that somehow - either through usage,
implementation or design change that the type of the StringComparer will
get changed.
For simplicity sake, I have removed error handling and warnings.
public abstract class Task{ //A class to facilitate error handling and
progress for blocking calls
public Dictionary<stri ng, Dictionary<stri ng, string>data;
protected abstract void execute();
public void ExecuteInBlocki ngCall(){
execute();
}
}
public class InitializeCaseI nsensitiveFileS torage : Task { //prepare
dictionaries to hold case insensitive local files
protected override void execute() {
string[] alwaysDelete = {"new_dest", "new_hash", "new_date"} ;
string[] alwaysCheck = {"old_date", "old_hash", "old_dest"} ;
foreach(string i in alwaysDelete){
if(data.Contain sKey(i))
data.Remove(i);
data.Add(i, new Dictionary<stri ng,
string>(StringC omparer.Ordinal IgnoreCase));
}
foreach(string i in alwaysCheck)
if(!data.Contai nsKey(i))
data.Add(i, new Dictionary<stri ng,
string>(StringC omparer.Ordinal IgnoreCase));
else if(data[i].Comparer!=Stri ngComparer.Ordi nalIgnoreCase){
data.Remove(i);
data.Add(i, new Dictionary<stri ng,
string>(StringC omparer.Ordinal IgnoreCase));
}
}
Is data[i].Comparer!=Stri ngComparer.Ordi nalIgnoreCase a reasonable way
to check and make sure that we are using the expected string comparer?
Will this work even after serialization? (I will add [Serializable]
tags and have this handled automatically)
Thank you
--
LTP
:)
I am trying to find a way to deal with Windows' case insensitivity
without just forcing everything lowercase. While I am open to criticism
on my method - my question relates to the fourth to bottom line (not
including curly braces) on the bottom - testing to see if the Comparer
is not StringComparer. OrdinalIgnoreCa se
My concern is eventually when I decide to serialize these to files, to
store persistant data, that somehow - either through usage,
implementation or design change that the type of the StringComparer will
get changed.
For simplicity sake, I have removed error handling and warnings.
public abstract class Task{ //A class to facilitate error handling and
progress for blocking calls
public Dictionary<stri ng, Dictionary<stri ng, string>data;
protected abstract void execute();
public void ExecuteInBlocki ngCall(){
execute();
}
}
public class InitializeCaseI nsensitiveFileS torage : Task { //prepare
dictionaries to hold case insensitive local files
protected override void execute() {
string[] alwaysDelete = {"new_dest", "new_hash", "new_date"} ;
string[] alwaysCheck = {"old_date", "old_hash", "old_dest"} ;
foreach(string i in alwaysDelete){
if(data.Contain sKey(i))
data.Remove(i);
data.Add(i, new Dictionary<stri ng,
string>(StringC omparer.Ordinal IgnoreCase));
}
foreach(string i in alwaysCheck)
if(!data.Contai nsKey(i))
data.Add(i, new Dictionary<stri ng,
string>(StringC omparer.Ordinal IgnoreCase));
else if(data[i].Comparer!=Stri ngComparer.Ordi nalIgnoreCase){
data.Remove(i);
data.Add(i, new Dictionary<stri ng,
string>(StringC omparer.Ordinal IgnoreCase));
}
}
Is data[i].Comparer!=Stri ngComparer.Ordi nalIgnoreCase a reasonable way
to check and make sure that we are using the expected string comparer?
Will this work even after serialization? (I will add [Serializable]
tags and have this handled automatically)
Thank you
--
LTP
:)
Comment