Clover.NET coverage report - Coverage

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

File Stats: LOC: 112   Methods: 3
NCLOC: 53 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Web\WebBuilders\ItemTemplates\CollectionItemTemplate.cs - 100,0 % 100,0 % 100,0 %
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.Collections;
26   using System.Reflection;
27   using System.Web.UI;
28   using System.Web.UI.WebControls;
29   using ShowX.Model;
30   using ShowX.Config;
31  
32   namespace ShowX.Web.WebBuilders.ItemTemplates
33   {
34   /// <summary>
35   /// CollectionItemTemplate represents template for item collection.
36   /// </summary>
37   public class CollectionItemTemplate : ITemplate {
38  
39   /// <summary>
40   /// Information of the property to map
41   /// </summary>
42   PropertyInfo propertyInfo;
43  
44   /// <summary>
45   /// Constructor.
46   /// </summary>
47   /// <param name="pInfo">PropertyInfo that represents collection property.</param>
48 35 public CollectionItemTemplate(PropertyInfo pInfo)
49   {
50 35 this.propertyInfo = pInfo;
51   }
52  
53   /// <summary>
54   /// Method called when instantiating a TemplateColumn by using this
55   /// ITemplate implementation.
56   /// </summary>
57   /// <param name="container">Container that instantiate this Template</param>
58 126 public void InstantiateIn(System.Web.UI.Control container)
59   {
60 126 System.Web.UI.WebControls.Label label = new System.Web.UI.WebControls.Label();
61 126 label.DataBinding += new EventHandler(TemplateControl_DataBinding);
62 126 container.Controls.Add(label);
63 126 label.Width = Unit.Percentage(100);
64   }
65  
66   /// <summary>
67   /// DataBinding Event related with a control of the template. Very useful to
68   /// assign correct values to template controls.
69   /// </summary>
70   /// <param name="sender">Sender who invoke the data binding.</param>
71   /// <param name="e">Arguments of the event.</param>
72 126 private void TemplateControl_DataBinding(object sender, System.EventArgs e)
73   {
74 126 ICollectionMap colmap = Configuration.Session.MappingHandler
75   .GetPropertyMap(propertyInfo) as ICollectionMap;
76  
77 126 System.Web.UI.WebControls.Label label;
78 126 label = (System.Web.UI.WebControls.Label) sender;
79 126 DataGridItem container = (DataGridItem) label.NamingContainer;
80  
81 126 ShowX.Web.WebControls.DataGrid dg = container.Parent.Parent
82   as ShowX.Web.WebControls.DataGrid;
83  
84 126 label.ControlStyle.MergeWith(dg.ChildControlStyle);
85  
86 126 ICollection values = DataBinder.Eval(container.DataItem,
87   propertyInfo.Name) as ICollection;
88  
89 126 string strValue = string.Empty;
90 126 PropertyInfo pi = Configuration.Session.MappingHandler
91   .GetPK(colmap.ContainedType);
92  
93 126 IIdentifierMap imap = Configuration.Session.MappingHandler
94   .GetPropertyMap(pi) as IIdentifierMap;
95  
96 126 string idProp = (imap.SubstituteAttr == "")
97   ? imap.Name : imap.SubstituteAttr;
98  
99 126 foreach(object o in values) {
100  
101 282 strValue += DataBinder.Eval(o,idProp) + ", ";
102   }
103  
104 126 strValue = (strValue != string.Empty)
105   ? strValue.Substring(0,strValue.Length-2)
106   : "(None)";
107  
108 126 label.Text = strValue;
109   }
110   }
111   }
112