Clover.NET coverage report - Coverage

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

File Stats: LOC: 127   Methods: 3
NCLOC: 63 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Web\WebBuilders\ItemTemplates\CollectionEditItemTemplate.cs 100,0 % 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 CollectionEditItemTemplate : 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 CollectionEditItemTemplate(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 4 public void InstantiateIn(System.Web.UI.Control container)
59   {
60 4 ShowX.Web.WebControls.CheckBoxList cblist = new ShowX.Web
61   .WebControls.CheckBoxList(this.propertyInfo);
62 4 cblist.DataBinding += new EventHandler(TemplateControl_DataBinding);
63 4 container.Controls.Add(cblist);
64 4 cblist.Width = Unit.Percentage(100);
65  
66 4 cblist.Validators.AddRange(Configuration.Session
67   .MappingHandler.GetValidators(propertyInfo));
68  
69   }
70  
71   /// <summary>
72   /// DataBinding Event related with a control of the template. Very useful to
73   /// assign correct values to template controls.
74   /// </summary>
75   /// <param name="sender">Sender who invoke the data binding.</param>
76   /// <param name="e">Arguments of the event.</param>
77 4 private void TemplateControl_DataBinding(object sender, System.EventArgs e)
78   {
79 4 ICollectionMap colmap = Configuration.Session.MappingHandler
80   .GetPropertyMap(propertyInfo) as ICollectionMap;
81  
82 4 ShowX.Web.WebControls.CheckBoxList cblist;
83 4 cblist = (ShowX.Web.WebControls.CheckBoxList) sender;
84  
85 4 DataGridItem container = (DataGridItem) cblist.NamingContainer;
86  
87 4 ShowX.Web.WebControls.DataGrid dg = container.Parent.Parent
88   as ShowX.Web.WebControls.DataGrid;
89  
90 4 cblist.MergeControlStyle(dg.ChildControlStyle);
91  
92 4 ICollection values = DataBinder.Eval(container.DataItem,
93   propertyInfo.Name) as ICollection;
94  
95 4 PropertyInfo pi = Configuration.Session.MappingHandler
96   .GetPK(colmap.ContainedType);
97  
98 4 IIdentifierMap imap = Configuration.Session.MappingHandler
99   .GetPropertyMap(pi) as IIdentifierMap;
100  
101 4 string idProp = (imap.SubstituteAttr == "")
102   ? imap.Name : imap.SubstituteAttr;
103  
104 4 ArrayList allValues = Configuration.Session.MethodCaller
105   .InvokeMethodGetAllX(colmap.ContainedType,dg.XContext);
106  
107 4 foreach(object o in allValues) {
108  
109 12 cblist.Items.Add(new ListItem(
110   DataBinder.Eval(o,idProp).ToString(),
111   DataBinder.Eval(o,imap.Name).ToString()));
112  
113 12 foreach (object o1 in values) {
114  
115   //Value is in the collection. Check
116 20 if (DataBinder.Eval(o,imap.Name).ToString() ==
117   DataBinder.Eval(o1,imap.Name).ToString()) {
118  
119 8 cblist.Items[cblist.Items.Count-1].Selected = true;
120 8 break;
121   }
122   }
123   }
124   }
125   }
126   }
127