Clover.NET coverage report - Coverage

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

File Stats: LOC: 396   Methods: 32
NCLOC: 269 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Scope\ConfigurationScope.cs 90.0 % 90.4 % 93.8 % 91.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 Using
28  
29   using System;
30   using System.Collections;
31   using System.Collections.Specialized;
32   using System.Configuration;
33   using System.Xml;
34   using IBatisNet.Common;
35   using IBatisNet.Common.Utilities;
36   using IBatisNet.Common.Utilities.Objects;
37   using IBatisNet.DataMapper.TypeHandlers;
38  
39   #endregion
40  
41   namespace IBatisNet.DataMapper.Scope
42   {
43   /// <summary>
44   /// The ConfigurationScope maintains the state of the build process.
45   /// </summary>
46   public class ConfigurationScope
47   {
48   #region Fields
49  
50   private ErrorContext _errorContext = null;
51   private HybridDictionary _providers = new HybridDictionary();
52   private NameValueCollection _properties = new NameValueCollection();
53  
54   private XmlDocument _sqlMapConfigDocument = null;
55   private XmlDocument _sqlMapDocument = null;
56   private XmlNode _nodeContext = null;
57  
58   private bool _useConfigFileWatcher = false;
59   private bool _useStatementNamespaces = false;
60   private bool _isCacheModelsEnabled = false;
61   private bool _useEmbedStatementParams = false;
62   private bool _validateSqlMap = false;
63   private bool _isCallFromDao = false;
64  
65   private SqlMapper _sqlMapper = null;
66   private string _sqlMapNamespace = null;
67   private DataSource _dataSource = null;
68   private bool _isXmlValid = true;
69  
70   #endregion
71  
72   #region Constructors
73  
74   /// <summary>
75   /// Default constructor
76   /// </summary>
77 170 public ConfigurationScope()
78   {
79 170 _errorContext = new ErrorContext();
80  
81 170 _providers.Clear();
82   }
83   #endregion
84  
85   #region Properties
86  
87   /// <summary>
88   /// Set if theparser should validate the sqlMap documents
89   /// </summary>
90   public bool ValidateSqlMap
91   {
92 170 set
93   {
94 170 _validateSqlMap = value;
95   }
96 1870 get
97   {
98 1870 return _validateSqlMap;
99   }
100   }
101  
102   /// <summary>
103   /// Tells us if the xml configuration file validate the schema
104   /// </summary>
105   public bool IsXmlValid
106   {
107 0 set
108   {
109   _isXmlValid = value;
110   }
111 170 get
112   {
113 170 return _isXmlValid;
114   }
115   }
116  
117  
118   /// <summary>
119   /// The current SqlMap namespace.
120   /// </summary>
121   public string SqlMapNamespace
122   {
123 1870 set
124   {
125 1870 _sqlMapNamespace = value;
126   }
127 107270 get
128   {
129 107270 return _sqlMapNamespace;
130   }
131   }
132  
133   /// <summary>
134   /// The SqlMapper we are building.
135   /// </summary>
136   public SqlMapper SqlMapper
137   {
138 170 set
139   {
140 170 _sqlMapper = value;
141   }
142 147390 get
143   {
144 147390 return _sqlMapper;
145   }
146   }
147  
148   /// <summary>
149   /// The current TypeHandlerFactory
150   /// </summary>
151   internal TypeHandlerFactory TypeHandlerFactory
152   {
153 134300 get
154   {
155 134300 return _sqlMapper.TypeHandlerFactory;
156   }
157   }
158  
159   /// <summary>
160   /// Tell us if we are in a DataAccess context.
161   /// </summary>
162   public bool IsCallFromDao
163   {
164 170 set
165   {
166 170 _isCallFromDao = value;
167   }
168 680 get
169   {
170 680 return _isCallFromDao;
171   }
172   }
173  
174   /// <summary>
175   /// Tell us if we cache model is enabled.
176   /// </summary>
177   public bool IsCacheModelsEnabled
178   {
179 170 set
180   {
181 170 _isCacheModelsEnabled = value;
182   }
183 2210 get
184   {
185 2210 return _isCacheModelsEnabled;
186   }
187   }
188  
189  
190   /// <summary>
191   /// External data source
192   /// </summary>
193   public DataSource DataSource
194   {
195 340 set
196   {
197 340 _dataSource = value;
198   }
199 41820 get
200   {
201 41820 return _dataSource;
202   }
203   }
204  
205   /// <summary>
206   /// The current context node we are analizing
207   /// </summary>
208   public XmlNode NodeContext
209   {
210 39610 set
211   {
212 39610 _nodeContext = value;
213   }
214 58480 get
215   {
216 58480 return _nodeContext;
217   }
218   }
219  
220   /// <summary>
221   /// The XML SqlMap config file
222   /// </summary>
223   public XmlDocument SqlMapConfigDocument
224   {
225 170 set
226   {
227 170 _sqlMapConfigDocument = value;
228   }
229 1190 get
230   {
231 1190 return _sqlMapConfigDocument;
232   }
233   }
234  
235   /// <summary>
236   /// A XML SqlMap file
237   /// </summary>
238   public XmlDocument SqlMapDocument
239   {
240 1870 set
241   {
242 1870 _sqlMapDocument = value;
243   }
244 21250 get
245   {
246 21250 return _sqlMapDocument;
247   }
248   }
249  
250   /// <summary>
251   /// Tell us if we use Configuration File Watcher
252   /// </summary>
253   public bool UseConfigFileWatcher
254   {
255 170 set
256   {
257 170 _useConfigFileWatcher = value;
258   }
259 1870 get
260   {
261 1870 return _useConfigFileWatcher;
262   }
263   }
264  
265   /// <summary>
266   /// Tell us if we use statements namespaces
267   /// </summary>
268   public bool UseStatementNamespaces
269   {
270 170 set
271   {
272 170 _useStatementNamespaces = value;
273   }
274 26010 get
275   {
276 26010 return _useStatementNamespaces;
277   }
278   }
279  
280   /// <summary>
281   /// Get the request's error context
282   /// </summary>
283   public ErrorContext ErrorContext
284   {
285 277100 get
286   {
287 277100 return _errorContext;
288   }
289   }
290  
291   /// <summary>
292   /// List of providers
293   /// </summary>
294   public HybridDictionary Providers
295   {
296 2040 get
297   {
298 2040 return _providers;
299   }
300   }
301  
302   /// <summary>
303   /// List of global properties
304   /// </summary>
305   public NameValueCollection Properties
306   {
307 37060 get
308   {
309 37060 return _properties;
310   }
311   }
312  
313   /// <summary>
314   /// Indicates if parameters should be embedded in the sql statement.
315   /// </summary>
316   public bool UseEmbedStatementParams
317   {
318 170 get
319   {
320 170 return _useEmbedStatementParams;
321   }
322 0 set
323   {
324   _useEmbedStatementParams = value;
325   }
326   }
327  
328   #endregion
329  
330   /// <summary>
331   ///
332   /// </summary>
333   /// <param name="clazz">Type of the ResultMap</param>
334   /// <param name="propertyName">Property name to map</param>
335   /// <param name="clrType"></param>
336   /// <param name="dbType"></param>
337   /// <returns></returns>
338 24310 public ITypeHandler ResolveTypeHandler(Type clazz, string propertyName, string clrType, string dbType)
339   {
340 24310 ITypeHandler handler = null;
341 24310 if (clazz==null)
342   {
343 0 handler = this.TypeHandlerFactory.GetUnkownTypeHandler();
344   }
345 24310 else if (typeof(IDictionary).IsAssignableFrom(clazz))
346   {
347   // IDictionary
348 2210 if (clrType.Length == 0)
349   {
350 680 handler = this.TypeHandlerFactory.GetUnkownTypeHandler();
351   }
352   else
353   {
354 1530 try
355   {
356 1530 Type type = Resources.TypeForName(clrType);
357 1530 handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
358   }
359   catch (Exception e)
360   {
361 0 throw new ConfigurationException("Error. Could not set TypeHandler. Cause: " + e.Message, e);
362   }
363   }
364   }
365 22100 else if (this.TypeHandlerFactory.GetTypeHandler(clazz, dbType) != null)
366   {
367   // Primitive
368 510 handler = this.TypeHandlerFactory.GetTypeHandler(clazz, dbType);
369   }
370   else
371   {
372   // .NET object
373 21590 if (clrType.Length == 0)
374   {
375 21250 Type type = ObjectProbe.GetPropertyTypeForGetter(clazz, propertyName);
376 21250 handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
377   }
378   else
379   {
380 340 try
381   {
382 340 Type type = Resources.TypeForName(clrType);
383 340 handler = this.TypeHandlerFactory.GetTypeHandler(type, dbType);
384   }
385   catch (Exception e)
386   {
387 0 throw new ConfigurationException("Error. Could not set TypeHandler. Cause: " + e.Message, e);
388   }
389   }
390   }
391  
392 24310 return handler;
393   }
394   }
395   }
396