1: using System;
2: using System.Web;
3: using System.Web.UI;
4:
5: namespace Ia.Cl.Model.AspNetState
6: {
7: ////////////////////////////////////////////////////////////////////////////
8:
9: /// <summary publish="true">
10: /// ASP.NET state support functions: Applications, Session, Coockies, Control.
11: /// </summary>
12: /// <value>
13: /// https://msdn.microsoft.com/en-us/library/z1hkazw7(v=vs.100).aspx
14: /// </value>
15: /// <remarks>
16: /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
17: ///
18: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
19: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
20: ///
21: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
22: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23: ///
24: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
25: ///
26: /// Copyright notice: This notice may not be removed or altered from any source distribution.
27: /// </remarks>
28: public class View
29: {
30: ////////////////////////////////////////////////////////////////////////////
31:
32: /// <summary>
33: ///
34: /// </summary>
35: public View() { }
36:
37: ////////////////////////////////////////////////////////////////////////////
38:
39: /// <summary>
40: ///
41: /// </summary>
42: public static void Write(StateBag viewState, string name, object value)
43: {
44: viewState[name] = value;
45: }
46:
47: ////////////////////////////////////////////////////////////////////////////
48:
49: /// <summary>
50: ///
51: /// </summary>
52: public static object Read(StateBag viewState, string name)
53: {
54: return viewState[name];
55: }
56:
57: ////////////////////////////////////////////////////////////////////////////
58: ////////////////////////////////////////////////////////////////////////////
59: }
60:
61: ////////////////////////////////////////////////////////////////////////////
62: ////////////////////////////////////////////////////////////////////////////
63:
64:
65:
66:
67:
68:
69: ////////////////////////////////////////////////////////////////////////////
70: ////////////////////////////////////////////////////////////////////////////
71:
72: /// <summary>
73: ///
74: /// </summary>
75: public class Control
76: {
77: ////////////////////////////////////////////////////////////////////////////
78:
79: /// <summary>
80: ///
81: /// </summary>
82: public Control() { }
83:
84: ////////////////////////////////////////////////////////////////////////////
85: ////////////////////////////////////////////////////////////////////////////
86: }
87:
88: ////////////////////////////////////////////////////////////////////////////
89: ////////////////////////////////////////////////////////////////////////////
90:
91:
92:
93:
94:
95:
96: ////////////////////////////////////////////////////////////////////////////
97: ////////////////////////////////////////////////////////////////////////////
98:
99: /// <summary>
100: ///
101: /// </summary>
102: public class Cookie
103: {
104: ////////////////////////////////////////////////////////////////////////////
105:
106: /// <summary>
107: ///
108: /// </summary>
109: public Cookie() { }
110:
111: ////////////////////////////////////////////////////////////////////////////
112:
113: /// <summary>
114: ///
115: /// </summary>
116: public static void Write(string name, string value)
117: {
118: Write(name, value, 9999);
119: }
120:
121: ////////////////////////////////////////////////////////////////////////////
122:
123: /// <summary>
124: ///
125: /// </summary>
126: public static void Write(string name, string value, int lifeInDays)
127: {
128: // this appends a cookie to the collection
129:
130: HttpCookie cookie = new HttpCookie(name, value)
131: {
132: Expires = DateTime.UtcNow.AddHours(3 + 24 * lifeInDays)
133: };
134:
135: HttpContext.Current.Response.Cookies.Add(cookie);
136: }
137:
138: ////////////////////////////////////////////////////////////////////////////
139:
140: /// <summary>
141: ///
142: /// </summary>
143: public static string Read(string name)
144: {
145: // this reads the value of the cookie
146: string value;
147: HttpCookie cookie;
148:
149: cookie = HttpContext.Current.Request.Cookies[name];
150:
151: if (cookie == null) value = null;
152: else value = cookie.Value;
153:
154: return value;
155: }
156:
157: ////////////////////////////////////////////////////////////////////////////
158: ////////////////////////////////////////////////////////////////////////////
159:
160:
161:
162:
163:
164:
165:
166:
167: ////////////////////////////////////////////////////////////////////////////
168: ////////////////////////////////////////////////////////////////////////////
169:
170: /// <summary>
171: ///
172: /// </summary>
173: public class Application
174: {
175: ////////////////////////////////////////////////////////////////////////////
176:
177: /// <summary>
178: ///
179: /// </summary>
180: public Application() { }
181:
182: ////////////////////////////////////////////////////////////////////////////
183: ////////////////////////////////////////////////////////////////////////////
184: }
185:
186: ////////////////////////////////////////////////////////////////////////////
187: ////////////////////////////////////////////////////////////////////////////
188:
189:
190:
191:
192:
193:
194: ////////////////////////////////////////////////////////////////////////////
195: ////////////////////////////////////////////////////////////////////////////
196:
197: /// <summary>
198: ///
199: /// </summary>
200: public class Session
201: {
202: ////////////////////////////////////////////////////////////////////////////
203:
204: /// <summary>
205: ///
206: /// </summary>
207: public Session() { }
208:
209: ////////////////////////////////////////////////////////////////////////////
210: ////////////////////////////////////////////////////////////////////////////
211: }
212:
213: ////////////////////////////////////////////////////////////////////////////
214: ////////////////////////////////////////////////////////////////////////////
215:
216: }
217: }