| |||||||||||||||||
Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
Web\Scripts\ScriptBaseClass.cs | 50,0 % | 100,0 % | 100,0 % | 87,5 % |
|
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.Web.UI; | |
25 | using log4net; | |
26 | ||
27 | namespace ShowX.Web.Scripts | |
28 | { | |
29 | /// <summary> | |
30 | /// ScriptBaseClass define a base class for all the generator script classes. | |
31 | /// </summary> | |
32 | public class ScriptBaseClass | |
33 | { | |
34 | private static readonly ILog log = LogManager.GetLogger( | |
35 | typeof( ScriptBaseClass)); | |
36 | ||
37 | /// <summary> | |
38 | /// Key of this script. | |
39 | /// </summary> | |
40 | private string key = "IncludeJSCalendarScriptBlock:Key"; | |
41 | ||
42 | /// <summary> | |
43 | /// JS Code of this script. | |
44 | /// </summary> | |
45 | protected string script; | |
46 | ||
47 | /// <summary> | |
48 | /// Public constructor. | |
49 | /// </summary> | |
50 | /// <param name="key">Key for registering this script.</param> | |
51 | 58 | public ScriptBaseClass(string key) |
52 | { | |
53 | 58 | this.key = key; |
54 | } | |
55 | ||
56 | /// <summary> | |
57 | /// Register the script block on the given page. | |
58 | /// </summary> | |
59 | /// <param name="page">The page to register the script</param> | |
60 | 58 | public void Register(Page page) |
61 | { | |
62 | 58 | if (!page.IsClientScriptBlockRegistered(this.key)) { |
63 | ||
64 | 58 | log.Info(string.Format("Registering script '{0}' of page '{1}' ", |
65 | this.key,page.GetType().Name)); | |
66 | ||
67 | 58 | page.RegisterStartupScript(this.key,this.script); |
68 | } | |
69 | } | |
70 | ||
71 | } | |
72 | } | |
73 |
|