2010-01-20 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mcs / class / System.Web / System.Web.UI / PageParserFilter.cs
1 //
2 // System.Web.UI.PageParserFilter.cs
3 //
4 // Authors:
5 //     Arina Itkes (arinai@mainsoft.com)
6 //
7 // (C) 2007 Mainsoft Co. (http://www.mainsoft.com)
8 //
9 //
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32 using System.Collections;
33
34 namespace System.Web.UI
35 {
36         public abstract class PageParserFilter
37         {
38                 TemplateParser parser;
39
40                 protected PageParserFilter ()
41                 {
42                 }
43                 
44                 public virtual bool AllowCode {
45                         get { return false; }
46                 }
47
48                 [MonoTODO ("Need to implement support for this in the parser")]
49                 protected int Line {
50                         get { return parser.Location.BeginLine; }
51                 }
52
53                 public virtual int NumberOfControlsAllowed {
54                         get { return 0; }
55                 }
56                 
57                 public virtual int NumberOfDirectDependenciesAllowed {
58                         get { return 0; }
59                 }
60                 
61                 public virtual int TotalNumberOfDependenciesAllowed {
62                         get { return 0; }
63                 }
64                 
65                 protected string VirtualPath {
66                         get { return parser.VirtualPath.Absolute; }
67                 }
68
69                 protected void AddControl (Type type, IDictionary attributes)
70                 {
71                         if (parser == null)
72                                 return;
73
74                         parser.AddControl (type, attributes);
75                 }
76                 
77                 public virtual bool AllowBaseType (Type baseType)
78                 {
79                         return false;
80                 }
81                 
82                 public virtual bool AllowControl (Type controlType, ControlBuilder builder)
83                 {
84                         return false;
85                 }
86                 
87                 public virtual bool AllowServerSideInclude (string includeVirtualPath)
88                 {
89                         return false;
90                 }
91                 
92                 public virtual bool AllowVirtualReference (string referenceVirtualPath, VirtualReferenceType referenceType)
93                 {
94                         return false;
95                 }
96                 
97                 public virtual CompilationMode GetCompilationMode (CompilationMode current)
98                 {
99                         return current;
100                 }
101
102                 public virtual Type GetNoCompileUserControlType ()
103                 {
104                         return null;
105                 }
106
107                 // LAMEDOC:
108                 // http://msdn.microsoft.com/en-us/library/system.web.ui.pageparserfilter.initialize.aspx
109                 // claims there's a virtualPath parameter, but there's none. Probably an internal
110                 // method is used to wrap a call to this one.
111                 protected virtual void Initialize ()
112                 {
113                 }
114
115                 internal void Initialize (TemplateParser parser)
116                 {
117                         this.parser = parser;
118                         Initialize ();
119                 }
120                 
121                 public virtual void ParseComplete (ControlBuilder rootBuilder)
122                 {
123                 }
124                 
125                 public virtual void PreprocessDirective (string directiveName, IDictionary attributes)
126                 {
127                 }
128                 
129                 public virtual bool ProcessCodeConstruct (CodeConstructType codeType, string code)
130                 {
131                         return false;
132                 }
133
134                 public virtual bool ProcessDataBindingAttribute (string controlId, string name, string value)
135                 {
136                         return false;
137                 }
138
139                 public virtual bool ProcessEventHookup (string controlId, string eventName, string handlerName)
140                 {
141                         return false;
142                 }
143
144                 protected void SetPageProperty (string filter, string name, string value)
145                 {
146                 }
147         }
148 }
149 #endif