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

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