Clover.NET coverage report - Coverage

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

File Stats: LOC: 119   Methods: 3
NCLOC: 59 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Web\WebBuilders\ItemTemplates\FKEditTemplate.cs 0,0 % 0,0 % 0,0 % 0,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.Config;
30   using ShowX.Model;
31   using DataGrid = ShowX.Web.WebControls.DataGrid;
32  
33   namespace ShowX.Web.WebBuilders.ItemTemplates
34   {
35   /// <summary>
36   /// This class is used to change the value of a FK attribute. This value is
37   /// changed by using a combo box.
38   /// </summary>
39   class FKEditTemplate : ITemplate {
40  
41   /// <summary>
42   /// Information of the property to map
43   /// </summary>
44   PropertyInfo propertyInfo;
45  
46   /// <summary>
47   /// Constructor
48   /// </summary>
49   /// <param name="propertyInfo">Information of the property to map</param>
50 0 public FKEditTemplate(PropertyInfo propertyInfo)
51   {
52   this.propertyInfo = propertyInfo;
53   }
54  
55   /// <summary>
56   /// Method called when instantiating a TemplateColumn by using this
57   /// ITemplate implementation
58   /// </summary>
59   /// <param name="container">Container that instantiate this Template</param>
60 0 public void InstantiateIn(Control container)
61   {
62   DropDownList ddl = new DropDownList();
63   ddl.DataBinding += new EventHandler(TemplateControl_DataBinding);
64   container.Controls.Add(ddl);
65   ddl.Width = Unit.Percentage(100);
66  
67   Literal lc = new Literal();
68   lc.Text += propertyInfo.Name;
69   lc.Visible = false;
70   container.Controls.Add(lc);
71   }
72  
73   /// <summary>
74   /// DataBinding Event related with a control of the template. Very useful to
75   /// assign correct values to template controls.
76   /// </summary>
77   /// <param name="sender">Sender who invoke the data binding</param>
78   /// <param name="e">Arguments of the event</param>
79 0 private void TemplateControl_DataBinding(object sender, EventArgs e)
80   {
81   PropertyInfo pi = Configuration.Session.MappingHandler
82   .GetPK(propertyInfo.PropertyType);
83  
84   IIdentifierMap dbpk = Configuration.Session.MappingHandler
85   .GetPropertyMap(pi) as IIdentifierMap;
86  
87   DropDownList ddl;
88   ddl = (DropDownList) sender;
89   DataGridItem container = (DataGridItem) ddl.NamingContainer;
90  
91   DataGrid dg = container.Parent.Parent
92   as DataGrid;
93  
94   ddl.ControlStyle.MergeWith(dg.ChildControlStyle);
95  
96   ArrayList values = Configuration.Session.MethodCaller
97   .InvokeMethodGetAllX(propertyInfo.PropertyType,dg.XContext);
98  
99   object aux = DataBinder.Eval(container.DataItem,
100   propertyInfo.Name + "."+ pi.Name);
101   int id = int.Parse(aux.ToString());
102   int currId = 0;
103  
104   for (int i = 0; i < values.Count; i++) {
105  
106   aux = DataBinder.Eval(values[i],dbpk.SubstituteAttr);
107   ddl.Items.Add(aux.ToString());
108  
109   aux = DataBinder.Eval(values[i],pi.Name);
110   currId = int.Parse(aux.ToString());
111   ddl.Items[i].Value = aux.ToString();
112  
113   if (id == currId)
114   ddl.SelectedIndex = i;
115   }
116   }
117   }
118   }
119