* SessionInProcHandler.cs: Use AppDomain.SetData so data is
[mono.git] / mcs / class / System.Web / System.Web.SessionState / SessionConfig.cs
1 //
2 // System.Web.SessionState.SessionConfig
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2003 Ximian, Inc (http://www.ximian.com)
8 //
9
10 using System;
11
12 namespace System.Web.SessionState
13 {
14         class SessionConfig
15         {
16                 internal SessionStateMode Mode;
17                 internal int Timeout; // minutes
18                 internal bool CookieLess;
19                 internal string StateConnectionString;
20                 internal string SqlConnectionString;
21                 internal string StateNetworkTimeout;
22
23                 public SessionConfig (object parent)
24                 {
25                         if (parent is SessionConfig) {
26                                 SessionConfig p = (SessionConfig) parent;
27                                 CookieLess = p.CookieLess;
28                                 Mode = p.Mode;
29                                 Timeout = p.Timeout;
30                                 StateConnectionString = p.StateConnectionString;
31                                 SqlConnectionString = p.SqlConnectionString;
32                         } else {
33                                 CookieLess = false;
34                                 Mode = SessionStateMode.InProc;
35                                 Timeout = 20;
36                                 StateConnectionString = "127.0.0.1:42424";
37                                 SqlConnectionString = "user id=sa;password=;data source=127.0.0.1";
38                         }
39                 }
40
41                 internal bool SetMode (string value)
42                 {
43                         try {
44                                 Mode = (SessionStateMode) Enum.Parse (typeof (SessionStateMode), value, true);
45                         } catch {
46                                 return false;
47                         }
48
49                         return true;
50                 }
51
52                 internal bool SetCookieLess (string value)
53                 {
54                         if (value == null)
55                                 return false;
56
57                         CookieLess = (0 == String.Compare ("true", value, true));
58                         if (!CookieLess && String.Compare ("false", value, true) != 0)
59                                 return false;
60
61                         return true;
62                 }
63
64                 internal bool SetTimeout (string value)
65                 {
66                         try {
67                                 Timeout = Int32.Parse (value);
68                         } catch {
69                                 return false;
70                         }
71                         
72                         return true;
73                 }
74
75                 internal void SetStateConnectionString (string value)
76                 {
77                         StateConnectionString = value;
78                 }
79
80                 internal void SetSqlConnectionString (string value)
81                 {
82                         SqlConnectionString = value;
83                 }
84
85                 internal void SetStateNetworkTimeout (string value)
86                 {
87                         StateNetworkTimeout = value;
88                 }
89         }
90 }
91