Added lookup by value

This commit is contained in:
Rich 2009-08-05 21:11:30 +00:00
parent a646c399a3
commit 52b74f47ed

View File

@ -61,6 +61,23 @@ namespace VEPROMS.CSLA.Library
public string value; public string value;
public rochild[] children; public rochild[] children;
}; };
public class roChild
{
rochild _MyChild;
public rochild MyChild
{
get { return _MyChild; }
set { _MyChild = value; }
}
public roChild(rochild myChild)
{
_MyChild = myChild;
}
public override string ToString()
{
return _MyChild.title;
}
};
#endregion #endregion
#region Local Data #region Local Data
private string _ROValue = ""; private string _ROValue = "";
@ -595,7 +612,38 @@ namespace VEPROMS.CSLA.Library
} }
return rtnstr; return rtnstr;
} }
private Dictionary<string, List<roChild>> _ValueLookupDictionary = null;
public List<roChild> GetRosByValue(string value)
{
if (_ValueLookupDictionary == null)
BuildValueDictionary();
if (value == string.Empty)
return null;
if(_ValueLookupDictionary.ContainsKey(value.ToUpper()))
return _ValueLookupDictionary[value.ToUpper()];
return null;
}
private void BuildValueDictionary()
{
_ValueLookupDictionary = new Dictionary<string, List<roChild>>();
if (dicRos == null)
ParseIntoDictionary(_ROFst != null ? _ROFst.ROLookup : _ROFstInfo.ROLookup);
foreach (rochild child in dicRos.Values)
{
if (child.value != null)
{
string value = child.value.ToUpper();
if (_ValueLookupDictionary.ContainsKey(value))
_ValueLookupDictionary[value].Add(new roChild(child));
else
{
List<roChild> children = new List<roChild>();
children.Add(new roChild(child));
_ValueLookupDictionary.Add(value, children);
}
}
}
}
private void ProcessMultiReturnValues(string str, int len) private void ProcessMultiReturnValues(string str, int len)
{ {
string tstr = str.Substring(0, len); string tstr = str.Substring(0, len);