CompilerParameters.ReferencedAssemblies do not have a set accessor
[mono.git] / mcs / class / System.Web / System.Web.Compilation / PageCompiler.cs
1 //
2 // System.Web.Compilation.PageCompiler
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
8 //
9 using System;
10 using System.CodeDom;
11 using System.IO;
12 using System.Reflection;
13 using System.Text;
14 using System.Web.UI;
15 using System.Web.SessionState;
16 using System.Web.Util;
17
18 namespace System.Web.Compilation
19 {
20         class PageCompiler : TemplateControlCompiler
21         {
22                 PageParser pageParser;
23                 static CodeTypeReference intRef = new CodeTypeReference (typeof (int));
24
25                 public PageCompiler (PageParser pageParser)
26                         : base (pageParser)
27                 {
28                         this.pageParser = pageParser;
29                 }
30
31                 protected override void AddInterfaces () 
32                 {
33                         base.AddInterfaces ();
34                         if (pageParser.EnableSessionState)
35                                 mainClass.BaseTypes.Add (new CodeTypeReference (typeof(IRequiresSessionState)));
36
37                         if (pageParser.ReadOnlySessionState)
38                                 mainClass.BaseTypes.Add (new CodeTypeReference (typeof (IReadOnlySessionState)));
39                 }
40
41                 void CreateGetTypeHashCode () 
42                 {
43                         CodeMemberMethod method = new CodeMemberMethod ();
44                         method.ReturnType = intRef;
45                         method.Name = "GetTypeHashCode";
46                         method.Attributes = MemberAttributes.Public | MemberAttributes.Override;
47                         Random rnd = new Random (pageParser.InputFile.GetHashCode ());
48                         method.Statements.Add (new CodeMethodReturnStatement (new CodePrimitiveExpression (rnd.Next ())));
49                         mainClass.Members.Add (method);
50                 }
51
52                 protected override void CreateMethods ()
53                 {
54                         base.CreateMethods ();
55
56                         CreateGetTypeHashCode ();
57                 }
58
59                 public static Type CompilePageType (PageParser pageParser)
60                 {
61                         PageCompiler compiler = new PageCompiler (pageParser);
62                         return compiler.GetCompiledType ();
63                 }
64         }
65 }
66