Example #1
0
        private int GetLocation(FixedSizeCache <string, string> .Entry AEntry)
        {
            FixedSizeCache <string, string> .Entry LEntry = GetHead();
            FixedSizeCache <string, string> .Entry LPrior = LEntry.GetType().GetField(CPriorName, CFieldFlags).GetValue(LEntry) as FixedSizeCache <string, string> .Entry;
            int i;

            for (i = 0; i < FTestCache.Size; i++)
            {
                if (LEntry == AEntry)
                {
                    return(i);
                }

                LEntry = LPrior;
                LPrior = LEntry.GetType().GetField(CPriorName, CFieldFlags).GetValue(LEntry) as FixedSizeCache <string, string> .Entry;
            }

            if (LEntry == AEntry)
            {
                return(i);
            }
            else
            {
                throw new Exception("Entry not in list");
            }
        }
Example #2
0
        private FixedSizeCache <string, string> .Entry GetHead()
        {
            if (FFixedSizeCacheType == null)
            {
                FFixedSizeCacheType = FTestCache.GetType();
            }

            return(FFixedSizeCacheType.GetField(CHeadName, CFieldFlags).GetValue(FTestCache) as FixedSizeCache <string, string> .Entry);
        }
Example #3
0
 private FixedSizeCache <string, string> .Entry GetEntry(int AKey)
 {
     FixedSizeCache <string, string> .Entry LEntry = GetHead();
     FixedSizeCache <string, string> .Entry LPrior = LEntry.GetType().GetField(CPriorName, CFieldFlags).GetValue(LEntry) as FixedSizeCache <string, string> .Entry;
     while (LEntry.Key != GetKey(AKey) && LPrior != null)
     {
         LEntry = LPrior;
         LPrior = LEntry.GetType().GetField(CPriorName, CFieldFlags).GetValue(LEntry) as FixedSizeCache <string, string> .Entry;
     }
     return(LEntry);
 }
Example #4
0
        private bool ValidateList()
        {
            FixedSizeCache <string, string> .Entry LEntry = GetHead();
            FixedSizeCache <string, string> .Entry LPrior = LEntry == null ? null : LEntry.GetType().GetField(CPriorName, CFieldFlags).GetValue(LEntry) as FixedSizeCache <string, string> .Entry;
            FixedSizeCache <string, string> .Entry LNext  = LEntry == null ? null : LEntry.GetType().GetField(CNextName, CFieldFlags).GetValue(LEntry) as FixedSizeCache <string, string> .Entry;

            if (LNext != null)
            {
                return(false);
            }

            for (int i = 1; i < FTestCache.Count; i++)
            {
                if (LPrior == null)
                {
                    return(false);
                }
                Assert.AreEqual(LEntry.Key.Replace("Key", "Value"), LEntry.Value);
                Assert.AreEqual(FTestCache[LEntry.Key], LEntry.Value);
                Assert.AreEqual(LEntry.Key.Replace("Key", "Value"), FTestCache[LEntry.Key]);

                LNext  = LEntry;
                LEntry = LPrior;
                if (LEntry.GetType().GetField(CNextName, CFieldFlags).GetValue(LEntry) != LNext)
                {
                    return(false);
                }

                LPrior = LEntry.GetType().GetField(CPriorName, CFieldFlags).GetValue(LEntry) as FixedSizeCache <string, string> .Entry;
            }

            if (LPrior != null)
            {
                return(false);
            }

            LNext  = LEntry;
            LEntry = LPrior;
            if (LEntry != null && LEntry.GetType().GetField(CNextName, CFieldFlags).GetValue(LEntry) != LNext)
            {
                return(false);
            }

            return(true);
        }
Example #5
0
 private int GetLastAccess(FixedSizeCache <string, string> .Entry AEntry)
 {
     return((int)AEntry.GetType().GetField(CLastAccessName, CFieldFlags).GetValue(AEntry));
 }
Example #6
0
 private bool GetPreCutoff(FixedSizeCache <string, string> .Entry AEntry)
 {
     return((bool)AEntry.GetType().GetField(CPreCutoffName, CFieldFlags).GetValue(AEntry));
 }
Example #7
0
 private FixedSizeCache <string, string> .Entry GetNext(FixedSizeCache <string, string> .Entry AEntry)
 {
     return(AEntry.GetType().GetField(CFNextName, CFieldFlags).GetValue(AEntry) as FixedSizeCache <string, string> .Entry);
 }