2 // System.Web.HttpBrowserCapabilities
5 // Patrik Torstensson (Patrik.Torstensson@labs2.com)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
8 // (c) 2003 Novell, Inc. (http://www.novell.com)
11 using System.Web.Configuration;
16 public class HttpBrowserCapabilities : HttpCapabilitiesBase
18 const int HaveActiveXControls = 1;
19 const int HaveAOL = 2;
20 const int HaveBackGroundSounds = 3;
21 const int HaveBeta = 4;
22 const int HaveBrowser = 5;
23 const int HaveCDF = 6;
24 const int HaveClrVersion = 7;
25 const int HaveCookies = 8;
26 const int HaveCrawler = 9;
27 const int HaveEcmaScriptVersion = 10;
28 const int HaveFrames = 11;
29 const int HaveJavaApplets = 12;
30 const int HaveJavaScript = 13;
31 const int HaveMajorVersion = 14;
32 const int HaveMinorVersion = 15;
33 const int HaveMSDomVersion = 16;
34 const int HavePlatform = 17;
35 const int HaveTables = 18;
36 const int HaveTagWriter = 19;
37 const int HaveVBScript = 20;
38 const int HaveVersion = 21;
39 const int HaveW3CDomVersion = 22;
40 const int HaveWin16 = 23;
41 const int HaveWin32 = 24;
46 bool backgroundSounds;
53 Version ecmaScriptVersion;
65 Version w3CDomVersion;
68 public HttpBrowserCapabilities () { }
70 public bool ActiveXControls {
72 if (!Get (HaveActiveXControls)) {
73 Set (HaveActiveXControls);
74 activeXControls = ReadBoolean ("activexcontrols", false);
77 return activeXControls;
85 aol = ReadBoolean ("aol", false);
92 public bool BackgroundSounds {
94 if (!Get (HaveBackGroundSounds)) {
95 Set (HaveBackGroundSounds);
96 backgroundSounds = ReadBoolean ("backgroundsounds", false);
99 return backgroundSounds;
105 if (!Get (HaveBeta)) {
107 beta = ReadBoolean ("beta", false);
114 public string Browser {
116 if (!Get (HaveBrowser)) {
118 browser = this ["browser"];
129 if (!Get (HaveCDF)) {
131 cdf = ReadBoolean ("cdf", false);
138 public Version ClrVersion {
140 if (!Get (HaveClrVersion)) {
141 Set (HaveClrVersion);
142 if (ReadBoolean ("netclr", false)) {
143 clrVersion = new Version (1, 0);
145 clrVersion = new Version (0, 0);
153 public bool Cookies {
155 if (!Get (HaveCookies)) {
157 cookies = ReadBoolean ("cookies", false);
164 public bool Crawler {
166 if (!Get (HaveCrawler)) {
168 crawler = ReadBoolean ("crawler", false);
176 public Version EcmaScriptVersion {
178 return new Version (0, 0);
184 if (!Get (HaveFrames)) {
186 frames = ReadBoolean ("frames", false);
193 public bool JavaApplets {
195 if (!Get (HaveJavaApplets)) {
196 Set (HaveJavaApplets);
197 javaApplets = ReadBoolean ("javaapplets", false);
204 public bool JavaScript {
206 if (!Get (HaveJavaScript)) {
207 Set (HaveJavaScript);
208 javaScript = ReadBoolean ("javascript", false);
215 public int MajorVersion {
217 if (!Get (HaveMajorVersion)) {
218 Set (HaveMajorVersion);
219 majorVersion = ReadInt32 ("majorver", 0);
226 public double MinorVersion {
228 if (!Get (HaveMinorVersion)) {
229 Set (HaveMinorVersion);
230 minorVersion = ReadDouble ("minorver", 0);
238 public Version MSDomVersion {
240 return new Version (0, 0);
244 public string Platform {
246 if (!Get (HavePlatform)) {
248 platform = this ["platform"];
249 if (platform == null)
259 if (!Get (HaveTables)) {
261 tables = ReadBoolean ("tables", false);
269 public Type TagWriter {
271 return typeof (HtmlTextWriter);
277 return Browser + MajorVersion;
281 public bool VBScript {
283 if (!Get (HaveVBScript)) {
285 vbscript = ReadBoolean ("vbscript", false);
292 public string Version {
294 if (!Get (HaveVersion)) {
296 version = this ["version"];
306 public Version W3CDomVersion {
308 return new Version (0, 0);
314 if (!Get (HaveWin16)) {
316 win16 = ReadBoolean ("win16", false);
329 bool ReadBoolean (string key, bool dflt)
331 string v = this [key];
335 return (v == "True");
338 int ReadInt32 (string key, int dflt)
340 string v = this [key];
345 return Int32.Parse (v);
351 double ReadDouble (string key, double dflt)
353 string v = this [key];
358 return Double.Parse (v);
366 return (flags & (1 << idx)) != 0;