Faster method of moving objects from a temporary cache list to indexed cache lists

This commit is contained in:
Rich
2010-09-29 17:21:30 +00:00
parent f3782ea2a2
commit 9f869343cd
55 changed files with 385 additions and 440 deletions

View File

@@ -78,20 +78,19 @@ namespace VEPROMS.CSLA.Library
private static Dictionary<string, List<ROImage>> _CacheByRODbID_FileName_DTS = new Dictionary<string, List<ROImage>>();
private static void ConvertListToDictionary()
{
List<ROImage> remove = new List<ROImage>();
foreach (ROImage tmp in _CacheList)
while (_CacheList.Count > 0) // Move ROImage(s) from temporary _CacheList to _CacheByPrimaryKey
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ImageID.ToString()))
ROImage tmp = _CacheList[0]; // Get the first ROImage
string pKey = tmp.ImageID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[tmp.ImageID.ToString()] = new List<ROImage>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[pKey] = new List<ROImage>(); // Add new list for PrimaryKey
_CacheByRODbID_FileName_DTS[tmp.RODbID.ToString() + "_" + tmp.FileName.ToString() + "_" + tmp.DTS.ToString()] = new List<ROImage>(); // Add new list for RODbID_FileName_DTS
}
_CacheByPrimaryKey[tmp.ImageID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheByRODbID_FileName_DTS[tmp.RODbID.ToString() + "_" + tmp.FileName.ToString() + "_" + tmp.DTS.ToString()].Add(tmp); // Unique Index
remove.Add(tmp);
_CacheList.RemoveAt(0); // Remove the first ROImage
}
foreach (ROImage tmp in remove)
RemoveFromCache(tmp);
}
protected static ROImage GetCachedByPrimaryKey(int imageID)
{