mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
add versions of search which provide default
This commit is contained in:
parent
d30bd82453
commit
f63fa06e0f
@ -173,8 +173,8 @@ namespace RusticiSoftware.Translator.Utils
|
|||||||
|
|
||||||
// search for name, given searchPath
|
// search for name, given searchPath
|
||||||
// searchPath is searched in reverse order
|
// searchPath is searched in reverse order
|
||||||
public TValue Search(List<string> searchPath, string name) {
|
public TValue Search(IList<string> searchPath, string name, TValue def) {
|
||||||
TValue ret = default(TValue);
|
TValue ret = def;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = searchPath.Count-1; i >= 0; i--) {
|
for (int i = searchPath.Count-1; i >= 0; i--) {
|
||||||
String ns = searchPath[i];
|
String ns = searchPath[i];
|
||||||
@ -194,10 +194,20 @@ namespace RusticiSoftware.Translator.Utils
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search for name, given searchPath
|
||||||
|
// searchPath is searched in reverse order
|
||||||
|
public TValue Search(IList<string> searchPath, string name) {
|
||||||
|
return Search(searchPath, name, default(TValue));
|
||||||
|
}
|
||||||
|
|
||||||
public TValue Search(string name) {
|
public TValue Search(string name) {
|
||||||
return Search(new List<string>(), name);
|
return Search(new List<string>(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TValue Search(string name, TValue def) {
|
||||||
|
return Search(new List<string>(), name, def);
|
||||||
|
}
|
||||||
|
|
||||||
public void Add(KeyValuePair<string, TValue> item)
|
public void Add(KeyValuePair<string, TValue> item)
|
||||||
{
|
{
|
||||||
this.Add(item.Key, item.Value);
|
this.Add(item.Key, item.Value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user