Clover.NET coverage report - Coverage

Coverage timestamp: viernes, 12 de agosto de 2005 12:53:38 PM

File Stats: LOC: 86   Methods: 1
NCLOC: 41 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Model\XmlModel\XmlObjectHandlerMethodCaller.cs 66,7 % 62,5 % 100,0 % 65,2 %
coverage coverage
1   #region Copyright
2   /*
3   ShowX. Maps business objects into presentation layer.
4   Copyright (C) 2005 Jesus Diaz.
5  
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Lesser General Public
8   License as published by the Free Software Foundation; either
9   version 2.1 of the License, or (at your option) any later version.
10  
11   This library is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   Lesser General Public License for more details.
15  
16   You should have received a copy of the GNU Lesser General Public
17   License along with this library; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  
20   For project details see: http://showx.sourceforge.net
21   */
22   #endregion
23  
24   using System;
25   using System.Reflection;
26   using ShowX.Config;
27   using ShowX.Session;
28   using log4net;
29  
30   namespace ShowX.Model.XmlModel
31   {
32   /// <summary>
33   /// Summary description for XmlObjectHandlerMethodCaller.
34   /// </summary>
35   public class XmlObjectHandlerMethodCaller : ObjectHandlerMethodCaller
36   {
37   private static readonly ILog log = LogManager.GetLogger(
38   typeof(XmlObjectHandlerMethodCaller));
39  
40   /// <summary>
41   /// Helper method to retrieve and build the Object Handler attached to a
42   /// certain type.
43   /// </summary>
44   /// <param name="t">Type to get object handler.</param>
45   /// <returns>An instance of the object handler attached to type t.</returns>
46 144 protected override IObjectHandler BuildObjectHandlerFromType(Type t)
47   {
48 144 XmlSession session = Configuration.Session as XmlSession;
49  
50 144 if (session[t] == null) {
51  
52 1 string errorMsg = string.Format(
53   "Attempt to use non registered type '{0}'",t.FullName);
54  
55 1 log.Fatal(errorMsg);
56 1 throw new ModelException(errorMsg);
57   }
58  
59 143 Type handler = session[t].HandlerType as Type;
60  
61 143 if (handler == null) {
62  
63 0 string errorMsg = string.Format(
64   "No object handler defined for type '{0}'",t.FullName);
65  
66 0 log.Fatal(errorMsg);
67 0 throw new ModelException(errorMsg);
68   }
69  
70 143 IObjectHandler objectHandler = handler.InvokeMember("",
71   BindingFlags.CreateInstance,null,null,null) as IObjectHandler;
72  
73 143 if (objectHandler == null) {
74  
75 0 string errorMsg = string.Format(
76   "Object handler for type {0} cannot be loaded",t.Name);
77  
78 0 log.Fatal(errorMsg);
79 0 throw new ModelException(errorMsg);
80   }
81  
82 143 return objectHandler;
83   }
84   }
85   }
86