Clover.NET coverage report - Coverage

Coverage timestamp: Friday, May 20, 2005 9:17:00 PM

File Stats: LOC: 127   Methods: 4
NCLOC: 51 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Configuration\Cache\Memory\MemoryCacheLevel.cs 50.0 % 90.0 % 100.0 % 87.5 %
coverage coverage
1  
2   #region Apache Notice
3   /*****************************************************************************
4   * $Header: $
5   * $Revision: $
6   * $Date: $
7   *
8   * iBATIS.NET Data Mapper
9   * Copyright (C) 2004 - Gilles Bayon
10   *
11   *
12   * Licensed under the Apache License, Version 2.0 (the "License");
13   * you may not use this file except in compliance with the License.
14   * You may obtain a copy of the License at
15   *
16   * http://www.apache.org/licenses/LICENSE-2.0
17   *
18   * Unless required by applicable law or agreed to in writing, software
19   * distributed under the License is distributed on an "AS IS" BASIS,
20   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21   * See the License for the specific language governing permissions and
22   * limitations under the License.
23   *
24   ********************************************************************************/
25   #endregion
26  
27   #region Imports
28   using System;
29   using System.Collections;
30  
31   using IBatisNet.DataMapper.Configuration.Cache;
32   using IBatisNet.DataMapper.Exceptions;
33   #endregion
34  
35   namespace IBatisNet.DataMapper.Configuration.Cache.Memory
36   {
37   /// <summary>
38   /// Summary description for MemoryCacheLevel.
39   /// </summary>
40   public class MemoryCacheLevel
41   {
42   #region Fields
43   private static Hashtable _cacheLevelMap = new Hashtable();
44  
45   /// <summary>
46   /// Constant for weak caching
47   /// This cache model is probably the best choice in most cases. It will increase
48   /// performance for popular results, but it will absolutely release the memory to
49   /// be used in allocating other objects, assuming that the results are not currently
50   /// in use.
51   /// References an object while still allowing it to be garbage collected.
52   /// </summary>
53   public static MemoryCacheLevel Weak;
54  
55   /// <summary>
56   /// Constant for strong caching.
57   /// This cache model will guarantee that the results stay in memory until the cache
58   /// is explicitly flushed. This is ideal for results that are:
59   /// <list>
60   /// <item>very small</item>
61   /// <item>absolutely static</item>
62   /// <item>used very often</item>
63   /// </list>
64   /// The advantage is that performance will be very good for this particular query.
65   /// The disadvantage is that if the memory used by these results is needed, then it
66   /// will not be released to make room for other objects (possibly more important
67   /// objects).
68   /// </summary>
69   public static MemoryCacheLevel Strong;
70  
71   private string _referenceType;
72   #endregion
73  
74   #region Constructor (s) / Destructor
75   /// <summary>
76   ///
77   /// </summary>
78 1 static MemoryCacheLevel()
79   {
80 1 Weak = new MemoryCacheLevel("WEAK");
81 1 Strong = new MemoryCacheLevel("STRONG");
82  
83 1 _cacheLevelMap[Weak.ReferenceType] = Weak;
84 1 _cacheLevelMap[Strong.ReferenceType] = Strong;
85   }
86   #endregion
87  
88   #region Methods
89   /// <summary>
90   /// Creates a new instance of CacheLevel
91   /// </summary>
92   /// <param name="type">The type of the CacheLevel.</param>
93 2 private MemoryCacheLevel(string type)
94   {
95 2 _referenceType = type;
96   }
97  
98   /// <summary>
99   ///
100   /// </summary>
101   public string ReferenceType
102   {
103 2 get
104   {
105 2 return _referenceType;
106   }
107   }
108  
109   /// <summary>
110   ///
111   /// </summary>
112   /// <param name="referenceType"></param>
113   /// <returns></returns>
114 170 public static MemoryCacheLevel GetByRefenceType(string referenceType)
115   {
116 170 MemoryCacheLevel cacheLevel = (MemoryCacheLevel)_cacheLevelMap[referenceType];
117 170 if (cacheLevel == null)
118   {
119 0 throw new DataMapperException("Error getting CacheLevel (reference type) for name: '" +referenceType+ "'.");
120   }
121 170 return cacheLevel;
122   }
123   #endregion
124  
125   }
126   }
127