1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
|
//------------------------------------------------------------------------------
// <copyright file="HttpCapabilitiesBase.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
/*
* Base class for browser capabilities object: just a read-only dictionary
* holder that supports Init()
*
*
*/
namespace System.Web.Configuration {
using System.Collections;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Web.Compilation;
using System.Web.UI;
using System.Web.Util;
using System.Web.UI.Adapters;
using Debug=System.Web.Util.Debug;
/*
* Abstract base class for Capabilities
*/
public class HttpCapabilitiesBase : IFilterResolutionService {
#if !DONTUSEFACTORYGENERATOR
private static FactoryGenerator _controlAdapterFactoryGenerator;
private static Hashtable _controlAdapterFactoryTable;
private static object _staticLock = new object();
#endif // DONTUSEFACTORYGENERATOR
private static object s_nullAdapterSingleton = new object();
private bool _useOptimizedCacheKey = true;
private static object _emptyHttpCapabilitiesBaseLock = new object();
private static HttpCapabilitiesProvider _browserCapabilitiesProvider = null;
private static HttpCapabilitiesBase _emptyHttpCapabilitiesBase;
internal static HttpCapabilitiesBase EmptyHttpCapabilitiesBase {
get {
if (_emptyHttpCapabilitiesBase != null) {
return _emptyHttpCapabilitiesBase;
}
lock (_emptyHttpCapabilitiesBaseLock) {
if (_emptyHttpCapabilitiesBase != null) {
return _emptyHttpCapabilitiesBase;
}
_emptyHttpCapabilitiesBase = new HttpCapabilitiesBase();
}
return _emptyHttpCapabilitiesBase;
}
}
public static HttpCapabilitiesProvider BrowserCapabilitiesProvider {
get {
return _browserCapabilitiesProvider;
}
set {
_browserCapabilitiesProvider = value;
}
}
public bool UseOptimizedCacheKey {
get {
return _useOptimizedCacheKey;
}
}
public void DisableOptimizedCacheKey() {
_useOptimizedCacheKey = false;
}
//
// Public API for retrieving capabilities from config.
//
// Note that this API will return an empty HttpCapabilitiesBase
// if capabilties cannot be found.
//
[ConfigurationPermission(SecurityAction.Assert, Unrestricted = true)]
public static HttpCapabilitiesBase GetConfigCapabilities(string configKey, HttpRequest request) {
HttpCapabilitiesBase capabilities = null;
if (configKey == "system.web/browserCaps") {
// Use cached config for system.web/browserCaps
capabilities = GetBrowserCapabilities(request);
}
else {
//
// Slower code path to get capabilities from any section
// that implements System.Web.Configuration.HttpCapabilitiesSectionHandler.
// This code path will hit a demand for ConfigurationPermission.
//
HttpCapabilitiesDefaultProvider capsbuilder = (HttpCapabilitiesDefaultProvider) request.Context.GetSection(configKey);
if (capsbuilder != null) {
if (BrowserCapabilitiesProvider != null) {
capsbuilder.BrowserCapabilitiesProvider = BrowserCapabilitiesProvider;
}
if (capsbuilder.BrowserCapabilitiesProvider == null) {
capabilities = capsbuilder.Evaluate(request);
}
else {
capabilities = capsbuilder.BrowserCapabilitiesProvider.GetBrowserCapabilities(request);
}
}
}
if (capabilities == null) {
capabilities = EmptyHttpCapabilitiesBase;
}
return capabilities;
}
//
// Get browser capabilities from config that are stored at "system.web/browserCaps".
//
// This code path will use the cached config object and avoid the demand for ConfigurationPermission
// after the first request for config.
//
// Note: this API will return null if the section isn't found.
//
internal static HttpBrowserCapabilities GetBrowserCapabilities(HttpRequest request) {
HttpCapabilitiesBase capabilities = null;
// Get the config evaluator from the cached config object.
HttpCapabilitiesDefaultProvider capsbuilder = request.Context.IsRuntimeErrorReported ?
RuntimeConfig.GetLKGConfig(request.Context).BrowserCaps : RuntimeConfig.GetConfig(request.Context).BrowserCaps;
if (capsbuilder != null) {
if (BrowserCapabilitiesProvider != null) {
capsbuilder.BrowserCapabilitiesProvider = BrowserCapabilitiesProvider;
}
if (capsbuilder.BrowserCapabilitiesProvider == null) {
capabilities = capsbuilder.Evaluate(request);
}
else {
capabilities = capsbuilder.BrowserCapabilitiesProvider.GetBrowserCapabilities(request);
}
}
return (HttpBrowserCapabilities) capabilities;
}
/*
* A Capabilities object is just a read-only dictionary
*/
/// <devdoc>
/// <para>Allows access to individual dictionary values.</para>
/// </devdoc>
public virtual String this[String key] {
get {
return (String)_items[key];
}
}
public HtmlTextWriter CreateHtmlTextWriter(TextWriter w) {
string mtw = HtmlTextWriter;
if (mtw != null && mtw.Length != 0) {
HtmlTextWriter writer = null;
try {
Type writerType = BuildManager.GetType(mtw, true /* throwOnFail */, false /* ignoreCase */);
object[] arr = new object[1];
arr[0] = w;
writer = (HtmlTextWriter)Activator.CreateInstance(writerType, arr);
if (writer != null) {
return writer;
}
}
catch {
throw new Exception(SR.GetString(SR.Could_not_create_type_instance, mtw));
}
}
return CreateHtmlTextWriterInternal(w);
}
internal HtmlTextWriter CreateHtmlTextWriterInternal(TextWriter tw) {
Type tagWriter = TagWriter;
if (tagWriter != null) {
return Page.CreateHtmlTextWriterFromType(tw, tagWriter);
}
// Fall back to Html 3.2
return new Html32TextWriter(tw);
}
/*
* It provides an overridable Init method
*/
/// <internalonly/>
/// <devdoc>
/// </devdoc>
protected virtual void Init() {
}
/*
* The actual initializer sets up Item[] before calling Init()
*/
internal void InitInternal(HttpBrowserCapabilities browserCaps) {
if (_items != null) {
throw new ArgumentException(SR.GetString(SR.Caps_cannot_be_inited_twice));
}
_items = browserCaps._items;
_adapters = browserCaps._adapters;
_browsers = browserCaps._browsers;
_htmlTextWriter = browserCaps._htmlTextWriter;
_useOptimizedCacheKey = browserCaps._useOptimizedCacheKey;
Init();
}
internal ControlAdapter GetAdapter(System.Web.UI.Control control) {
if (_adapters == null || _adapters.Count == 0) {
return null;
}
if (control == null) {
return null;
}
//see if we have already cached the type;
Type controlType = control.GetType();
object o = AdapterTypes[controlType];
// Common desktop case: simply return null since we already tried to resolve the adapter.
if (object.ReferenceEquals(o, s_nullAdapterSingleton))
return null;
Type adapterType = (Type)o;
if (adapterType == null) {
Type tempControlType = controlType;
string controlTypename = null;
string adapterTypename = null;
while (adapterTypename == null && tempControlType != typeof(Control)) {
controlTypename = tempControlType.AssemblyQualifiedName;
adapterTypename = (string)Adapters[controlTypename];
if (adapterTypename == null) {
controlTypename = tempControlType.FullName;
adapterTypename = (string)Adapters[controlTypename];
}
if (adapterTypename != null) {
break;
}
tempControlType = tempControlType.BaseType;
}
// Remember it so that we do not walk the control hierarchy again.
if (String.IsNullOrEmpty(adapterTypename)) {
AdapterTypes[controlType] = s_nullAdapterSingleton;
return null;
}
//do not thrownOnFail or ignoreCase
adapterType = BuildManager.GetType(adapterTypename, false, false);
if (adapterType == null) {
throw new Exception(SR.GetString(SR.ControlAdapters_TypeNotFound, adapterTypename));
}
AdapterTypes[controlType] = adapterType;
}
#if DONTUSEFACTORYGENERATOR
ControlAdapter adapter = (ControlAdapter) HttpRuntime.CreatePublicInstance(adapterType);
#else
IWebObjectFactory factory = GetAdapterFactory(adapterType);
ControlAdapter adapter = (ControlAdapter)factory.CreateInstance();
#endif // DONTUSEFACTORYGENERATOR
adapter._control = control;
return adapter;
}
#if !DONTUSEFACTORYGENERATOR
private IWebObjectFactory GetAdapterFactory(Type adapterType) {
if (_controlAdapterFactoryGenerator == null) {
lock (_staticLock) {
if (_controlAdapterFactoryGenerator == null) {
_controlAdapterFactoryTable = new Hashtable();
_controlAdapterFactoryGenerator = new FactoryGenerator();
}
}
}
IWebObjectFactory factory = (IWebObjectFactory)_controlAdapterFactoryTable[adapterType];
if (factory == null) {
lock (_controlAdapterFactoryTable.SyncRoot) {
factory = (IWebObjectFactory)_controlAdapterFactoryTable[adapterType];
if (factory == null) {
try {
factory = _controlAdapterFactoryGenerator.CreateFactory(adapterType);
}
catch {
throw new Exception(SR.GetString(SR.Could_not_create_type_instance, adapterType.ToString()));
}
_controlAdapterFactoryTable[adapterType] = factory;
}
}
}
return factory;
}
#endif // DONTUSEFACTORYGENERATOR
public IDictionary Capabilities {
get {
return _items;
}
set {
_items = value;
}
}
public IDictionary Adapters {
get {
if (_adapters == null) {
lock (_staticLock) {
if (_adapters == null) {
_adapters = new Hashtable(StringComparer.OrdinalIgnoreCase);
}
}
}
return _adapters;
}
}
public string HtmlTextWriter {
get {
return _htmlTextWriter;
}
set {
_htmlTextWriter = value;
}
}
private Hashtable AdapterTypes {
get {
if (_adapterTypes == null) {
lock (_staticLock) {
if (_adapterTypes == null) {
_adapterTypes = Hashtable.Synchronized(new Hashtable());
}
}
}
return _adapterTypes;
}
}
public string Id {
get {
if (_browsers != null) {
return (string)_browsers[_browsers.Count - 1];
}
else return String.Empty;
}
}
public ArrayList Browsers {
get {
return _browsers;
}
}
Hashtable _adapterTypes;
private IDictionary _adapters;
private string _htmlTextWriter;
private IDictionary _items;
public Version ClrVersion {
get {
Version[] clrVersions = GetClrVersions();
if (clrVersions != null) {
return clrVersions[clrVersions.Length - 1];
}
return null;
}
}
public Version[] GetClrVersions() {
string ua = HttpCapabilitiesDefaultProvider.GetUserAgent(HttpContext.Current.Request);
if (String.IsNullOrEmpty(ua)) {
return null;
}
// Adding timeout for Regex in case of malicious UA string causing DoS
Regex regex = RegexUtil.CreateRegex("\\.NET CLR (?'clrVersion'[0-9\\.]*)", RegexOptions.None);
MatchCollection matches = regex.Matches(ua);
if (matches.Count == 0) {
return new Version[1] { new Version() };
}
ArrayList versionList = new ArrayList();
foreach (Match match in matches) {
try {
Version version = new Version(match.Groups["clrVersion"].Value);
versionList.Add(version);
}
catch (System.FormatException) {
//got imvalid version data
}
}
versionList.Sort();
return (Version[])versionList.ToArray(typeof(Version));
}
public string Type {
get {
if (!_havetype) {
_type = this["type"];
_havetype = true;
}
return _type;
}
}
public string Browser {
get {
if (!_havebrowser) {
_browser = this["browser"];
_havebrowser = true;
}
return _browser;
}
}
public string Version {
get {
if (!_haveversion) {
_version = this["version"];
_haveversion = true;
}
return _version;
}
}
public int MajorVersion {
get {
if (!_havemajorversion) {
try {
_majorversion = int.Parse(this["majorversion"], CultureInfo.InvariantCulture);
_havemajorversion = true;
}
catch (FormatException e) {
throw BuildParseError(e, "majorversion");
}
}
return _majorversion;
}
}
Exception BuildParseError(Exception e, string capsKey) {
string message = SR.GetString(SR.Invalid_string_from_browser_caps, e.Message, capsKey, this[capsKey]);
// to show ConfigurationException in stack trace
ConfigurationErrorsException configEx = new ConfigurationErrorsException(message, e);
// I want it to look like an unhandled exception
HttpUnhandledException httpUnhandledEx = new HttpUnhandledException(null, null);
// but show message from outer exception (it normally shows the inner-most)
httpUnhandledEx.SetFormatter(new UseLastUnhandledErrorFormatter(configEx));
return httpUnhandledEx;
}
bool CapsParseBoolDefault(string capsKey, bool defaultValue) {
string value = this[capsKey];
if (value == null) {
return defaultValue;
}
try {
return bool.Parse(value);
}
catch (FormatException) {
return defaultValue;
}
}
bool CapsParseBool(string capsKey) {
try {
return bool.Parse(this[capsKey]);
}
catch (FormatException e) {
throw BuildParseError(e, capsKey);
}
}
public string MinorVersionString {
get {
return this["minorversion"];
}
}
public double MinorVersion {
get {
if (!_haveminorversion) {
lock(_staticLock) {
if (!_haveminorversion)
{
try
{
// see ASURT 11176
_minorversion = double.Parse(
this["minorversion"],
NumberStyles.Float | NumberStyles.AllowDecimalPoint,
NumberFormatInfo.InvariantInfo);
_haveminorversion = true;
}
catch (FormatException e)
{
// Check if there's more than one decimal
// The only exception case we handle is of form .4.1, it becomes .4
string minor = this["minorversion"];
int firstDecimal = minor.IndexOf('.');
if (firstDecimal != -1)
{
int nextDecimal = minor.IndexOf('.', firstDecimal + 1);
if (nextDecimal != -1)
{
try
{
_minorversion = double.Parse(
minor.Substring(0, nextDecimal),
NumberStyles.Float | NumberStyles.AllowDecimalPoint,
NumberFormatInfo.InvariantInfo);
Thread.MemoryBarrier();
_haveminorversion = true;
}
catch (FormatException)
{
}
}
}
if (!_haveminorversion)
{
throw BuildParseError(e, "minorversion");
}
}
}
}
}
return _minorversion;
}
}
public string Platform {
get {
if (!_haveplatform) {
_platform = this["platform"];
_haveplatform = true;
}
return _platform;
}
}
public Type TagWriter {
get {
try {
if (!_havetagwriter) {
string tagWriter = this["tagwriter"];
if (String.IsNullOrEmpty(tagWriter)) {
_tagwriter = null;
}
else if (string.Compare(tagWriter, typeof(System.Web.UI.HtmlTextWriter).FullName, StringComparison.Ordinal) == 0) {
_tagwriter = typeof(System.Web.UI.HtmlTextWriter);
}
else {
_tagwriter = BuildManager.GetType(tagWriter, true /*throwOnError*/);
}
_havetagwriter = true;
}
}
catch (Exception e) {
throw BuildParseError(e, "tagwriter");
}
return _tagwriter;
}
}
public Version EcmaScriptVersion {
get {
if (!_haveecmascriptversion) {
_ecmascriptversion = new Version(this["ecmascriptversion"]);
_haveecmascriptversion = true;
}
return _ecmascriptversion;
}
}
public Version MSDomVersion {
get {
if (!_havemsdomversion) {
_msdomversion = new Version(this["msdomversion"]);
_havemsdomversion = true;
}
return _msdomversion;
}
}
public Version W3CDomVersion {
get {
if (!_havew3cdomversion) {
_w3cdomversion = new Version(this["w3cdomversion"]);
_havew3cdomversion = true;
}
return _w3cdomversion;
}
}
public bool Beta {
get {
if (!_havebeta) {
_beta = CapsParseBool("beta");
_havebeta = true;
}
return _beta;
}
}
public bool Crawler {
get {
if (!_havecrawler) {
_crawler = CapsParseBool("crawler");
_havecrawler = true;
}
return _crawler;
}
}
public bool AOL {
get {
if (!_haveaol) {
_aol = CapsParseBool("aol");
_haveaol = true;
}
return _aol;
}
}
public bool Win16 {
get {
if (!_havewin16) {
_win16 = CapsParseBool("win16");
_havewin16 = true;
}
return _win16;
}
}
public bool Win32 {
get {
if (!_havewin32) {
_win32 = CapsParseBool("win32");
_havewin32 = true;
}
return _win32;
}
}
public bool Frames {
get {
if (!_haveframes) {
_frames = CapsParseBool("frames");
_haveframes = true;
}
return _frames;
}
}
public bool RequiresControlStateInSession {
get {
if (!_haverequiresControlStateInSession) {
if (this["requiresControlStateInSession"] != null) {
_requiresControlStateInSession = CapsParseBoolDefault("requiresControlStateInSession", false);
}
_haverequiresControlStateInSession = true;
}
return _requiresControlStateInSession;
}
}
public bool Tables {
get {
if (!_havetables) {
_tables = CapsParseBool("tables");
_havetables = true;
}
return _tables;
}
}
public bool Cookies {
get {
if (!_havecookies) {
_cookies = CapsParseBool("cookies");
_havecookies = true;
}
return _cookies;
}
}
public bool VBScript {
get {
if (!_havevbscript) {
_vbscript = CapsParseBool("vbscript");
_havevbscript = true;
}
return _vbscript;
}
}
[Obsolete("The recommended alternative is the EcmaScriptVersion property. A Major version value greater than or equal to 1 implies JavaScript support. http://go.microsoft.com/fwlink/?linkid=14202")]
public bool JavaScript {
get {
if (!_havejavascript) {
_javascript = CapsParseBool("javascript");
_havejavascript = true;
}
return _javascript;
}
}
public bool JavaApplets {
get {
if (!_havejavaapplets) {
_javaapplets = CapsParseBool("javaapplets");
_havejavaapplets = true;
}
return _javaapplets;
}
}
public Version JScriptVersion {
get {
if (!_havejscriptversion) {
_jscriptversion = new Version(this["jscriptversion"]);
_havejscriptversion = true;
}
return _jscriptversion;
}
}
public bool ActiveXControls {
get {
if (!_haveactivexcontrols) {
_activexcontrols = CapsParseBool("activexcontrols");
_haveactivexcontrols = true;
}
return _activexcontrols;
}
}
public bool BackgroundSounds {
get {
if (!_havebackgroundsounds) {
_backgroundsounds = CapsParseBool("backgroundsounds");
_havebackgroundsounds = true;
}
return _backgroundsounds;
}
}
public bool CDF {
get {
if (!_havecdf) {
_cdf = CapsParseBool("cdf");
_havecdf = true;
}
return _cdf;
}
}
//previously in System.Web.Mobile
public virtual String MobileDeviceManufacturer {
get {
if (!_haveMobileDeviceManufacturer) {
_mobileDeviceManufacturer = this["mobileDeviceManufacturer"];
_haveMobileDeviceManufacturer = true;
}
return _mobileDeviceManufacturer;
}
}
public virtual String MobileDeviceModel {
get {
if (!_haveMobileDeviceModel) {
_mobileDeviceModel = this["mobileDeviceModel"];
_haveMobileDeviceModel = true;
}
return _mobileDeviceModel;
}
}
public virtual String GatewayVersion {
get {
if (!_haveGatewayVersion) {
_gatewayVersion = this["gatewayVersion"];
_haveGatewayVersion = true;
}
return _gatewayVersion;
}
}
public virtual int GatewayMajorVersion {
get {
if (!_haveGatewayMajorVersion) {
_gatewayMajorVersion = Convert.ToInt32(this["gatewayMajorVersion"], CultureInfo.InvariantCulture);
_haveGatewayMajorVersion = true;
}
return _gatewayMajorVersion;
}
}
public virtual double GatewayMinorVersion {
get {
if (!_haveGatewayMinorVersion) {
// The conversion below does not use Convert.ToDouble()
// because it depends on the current locale. So a german machine it would look for
// a comma as a seperator "1,5" where all user-agent strings use english
// decimal points "1.5". URT11176
//
_gatewayMinorVersion = double.Parse(
this["gatewayMinorVersion"],
NumberStyles.Float | NumberStyles.AllowDecimalPoint,
NumberFormatInfo.InvariantInfo);
_haveGatewayMinorVersion = true;
}
return _gatewayMinorVersion;
}
}
public virtual String PreferredRenderingType {
get {
if (!_havePreferredRenderingType) {
_preferredRenderingType = this["preferredRenderingType"];
_havePreferredRenderingType = true;
}
return _preferredRenderingType;
}
}
public virtual String PreferredRequestEncoding {
get {
if (!_havePreferredRequestEncoding) {
_preferredRequestEncoding = this["preferredRequestEncoding"];
Thread.MemoryBarrier();
_havePreferredRequestEncoding = true;
}
return _preferredRequestEncoding;
}
}
public virtual String PreferredResponseEncoding {
get {
if (!_havePreferredResponseEncoding) {
_preferredResponseEncoding = this["preferredResponseEncoding"];
_havePreferredResponseEncoding = true;
}
return _preferredResponseEncoding;
}
}
public virtual String PreferredRenderingMime {
get {
if (!_havePreferredRenderingMime) {
_preferredRenderingMime = this["preferredRenderingMime"];
_havePreferredRenderingMime = true;
}
return _preferredRenderingMime;
}
}
public virtual String PreferredImageMime {
get {
if (!_havePreferredImageMime) {
_preferredImageMime = this["preferredImageMime"];
_havePreferredImageMime = true;
}
return _preferredImageMime;
}
}
public virtual int ScreenCharactersWidth {
get {
if (!_haveScreenCharactersWidth) {
if (this["screenCharactersWidth"] == null) {
// calculate from best partial information
int screenPixelsWidthToUse = 640;
int characterWidthToUse = 8;
if (this["screenPixelsWidth"] != null && this["characterWidth"] != null) {
screenPixelsWidthToUse = Convert.ToInt32(this["screenPixelsWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = Convert.ToInt32(this["characterWidth"], CultureInfo.InvariantCulture);
}
else if (this["screenPixelsWidth"] != null) {
screenPixelsWidthToUse = Convert.ToInt32(this["screenPixelsWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = Convert.ToInt32(this["defaultCharacterWidth"], CultureInfo.InvariantCulture);
}
else if (this["characterWidth"] != null) {
screenPixelsWidthToUse = Convert.ToInt32(this["defaultScreenPixelsWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = Convert.ToInt32(this["characterWidth"], CultureInfo.InvariantCulture);
}
else if (this["defaultScreenCharactersWidth"] != null) {
screenPixelsWidthToUse = Convert.ToInt32(this["defaultScreenCharactersWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = 1;
}
_screenCharactersWidth = screenPixelsWidthToUse / characterWidthToUse;
}
else {
_screenCharactersWidth = Convert.ToInt32(this["screenCharactersWidth"], CultureInfo.InvariantCulture);
}
_haveScreenCharactersWidth = true;
}
return _screenCharactersWidth;
}
}
public virtual int ScreenCharactersHeight {
get {
if (!_haveScreenCharactersHeight) {
if (this["screenCharactersHeight"] == null) {
// calculate from best partial information
int screenPixelHeightToUse = 480;
int characterHeightToUse = 12;
if (this["screenPixelsHeight"] != null && this["characterHeight"] != null) {
screenPixelHeightToUse = Convert.ToInt32(this["screenPixelsHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = Convert.ToInt32(this["characterHeight"], CultureInfo.InvariantCulture);
}
else if (this["screenPixelsHeight"] != null) {
screenPixelHeightToUse = Convert.ToInt32(this["screenPixelsHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = Convert.ToInt32(this["defaultCharacterHeight"], CultureInfo.InvariantCulture);
}
else if (this["characterHeight"] != null) {
screenPixelHeightToUse = Convert.ToInt32(this["defaultScreenPixelsHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = Convert.ToInt32(this["characterHeight"], CultureInfo.InvariantCulture);
}
else if (this["defaultScreenCharactersHeight"] != null) {
screenPixelHeightToUse = Convert.ToInt32(this["defaultScreenCharactersHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = 1;
}
_screenCharactersHeight = screenPixelHeightToUse / characterHeightToUse;
}
else {
_screenCharactersHeight = Convert.ToInt32(this["screenCharactersHeight"], CultureInfo.InvariantCulture);
}
_haveScreenCharactersHeight = true;
}
return _screenCharactersHeight;
}
}
public virtual int ScreenPixelsWidth {
get {
if (!_haveScreenPixelsWidth) {
if (this["screenPixelsWidth"] == null) {
// calculate from best partial information
int screenCharactersWidthToUse = 80;
int characterWidthToUse = 8;
if (this["screenCharactersWidth"] != null && this["characterWidth"] != null) {
screenCharactersWidthToUse = Convert.ToInt32(this["screenCharactersWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = Convert.ToInt32(this["characterWidth"], CultureInfo.InvariantCulture);
}
else if (this["screenCharactersWidth"] != null) {
screenCharactersWidthToUse = Convert.ToInt32(this["screenCharactersWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = Convert.ToInt32(this["defaultCharacterWidth"], CultureInfo.InvariantCulture);
}
else if (this["characterWidth"] != null) {
screenCharactersWidthToUse = Convert.ToInt32(this["defaultScreenCharactersWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = Convert.ToInt32(this["characterWidth"], CultureInfo.InvariantCulture);
}
else if (this["defaultScreenPixelsWidth"] != null) {
screenCharactersWidthToUse = Convert.ToInt32(this["defaultScreenPixelsWidth"], CultureInfo.InvariantCulture);
characterWidthToUse = 1;
}
_screenPixelsWidth = screenCharactersWidthToUse * characterWidthToUse;
}
else {
_screenPixelsWidth = Convert.ToInt32(this["screenPixelsWidth"], CultureInfo.InvariantCulture);
}
_haveScreenPixelsWidth = true;
}
return _screenPixelsWidth;
}
}
public virtual int ScreenPixelsHeight {
get {
if (!_haveScreenPixelsHeight) {
if (this["screenPixelsHeight"] == null) {
int screenCharactersHeightToUse = 480 / 12;
int characterHeightToUse = 12;
if (this["screenCharactersHeight"] != null && this["characterHeight"] != null) {
screenCharactersHeightToUse = Convert.ToInt32(this["screenCharactersHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = Convert.ToInt32(this["characterHeight"], CultureInfo.InvariantCulture);
}
else if (this["screenCharactersHeight"] != null) {
screenCharactersHeightToUse = Convert.ToInt32(this["screenCharactersHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = Convert.ToInt32(this["defaultCharacterHeight"], CultureInfo.InvariantCulture);
}
else if (this["characterHeight"] != null) {
screenCharactersHeightToUse = Convert.ToInt32(this["defaultScreenCharactersHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = Convert.ToInt32(this["characterHeight"], CultureInfo.InvariantCulture);
}
else if (this["defaultScreenPixelsHeight"] != null) {
screenCharactersHeightToUse = Convert.ToInt32(this["defaultScreenPixelsHeight"], CultureInfo.InvariantCulture);
characterHeightToUse = 1;
}
_screenPixelsHeight = screenCharactersHeightToUse * characterHeightToUse;
}
else {
_screenPixelsHeight = Convert.ToInt32(this["screenPixelsHeight"], CultureInfo.InvariantCulture);
}
_haveScreenPixelsHeight = true;
}
return _screenPixelsHeight;
}
}
public virtual int ScreenBitDepth {
get {
if (!_haveScreenBitDepth) {
_screenBitDepth = Convert.ToInt32(this["screenBitDepth"], CultureInfo.InvariantCulture);
_haveScreenBitDepth = true;
}
return _screenBitDepth;
}
}
public virtual bool IsColor {
get {
if (!_haveIsColor) {
String isColorString = this["isColor"];
if (isColorString == null) {
_isColor = false;
}
else {
_isColor = Convert.ToBoolean(this["isColor"], CultureInfo.InvariantCulture);
}
_haveIsColor = true;
}
return _isColor;
}
}
public virtual String InputType {
get {
if (!_haveInputType) {
_inputType = this["inputType"];
_haveInputType = true;
}
return _inputType;
}
}
public virtual int NumberOfSoftkeys {
get {
if (!_haveNumberOfSoftkeys) {
_numberOfSoftkeys = Convert.ToInt32(this["numberOfSoftkeys"], CultureInfo.InvariantCulture);
_haveNumberOfSoftkeys = true;
}
return _numberOfSoftkeys;
}
}
public virtual int MaximumSoftkeyLabelLength {
get {
if (!_haveMaximumSoftkeyLabelLength) {
_maximumSoftkeyLabelLength = Convert.ToInt32(this["maximumSoftkeyLabelLength"], CultureInfo.InvariantCulture);
_haveMaximumSoftkeyLabelLength = true;
}
return _maximumSoftkeyLabelLength;
}
}
public virtual bool CanInitiateVoiceCall {
get {
if (!_haveCanInitiateVoiceCall) {
_canInitiateVoiceCall = CapsParseBoolDefault("canInitiateVoiceCall", false);
_haveCanInitiateVoiceCall = true;
}
return _canInitiateVoiceCall;
}
}
public virtual bool CanSendMail {
get {
if (!_haveCanSendMail) {
_canSendMail = CapsParseBoolDefault("canSendMail", true);
_haveCanSendMail = true;
}
return _canSendMail;
}
}
public virtual bool HasBackButton {
get {
if (!_haveHasBackButton) {
_hasBackButton = CapsParseBoolDefault("hasBackButton", true);
_haveHasBackButton = true;
}
return _hasBackButton;
}
}
public virtual bool RendersWmlDoAcceptsInline {
get {
if (!_haveRendersWmlDoAcceptsInline) {
_rendersWmlDoAcceptsInline = CapsParseBoolDefault("rendersWmlDoAcceptsInline", true);
_haveRendersWmlDoAcceptsInline = true;
}
return _rendersWmlDoAcceptsInline;
}
}
public virtual bool RendersWmlSelectsAsMenuCards {
get {
if (!_haveRendersWmlSelectsAsMenuCards) {
_rendersWmlSelectsAsMenuCards = CapsParseBoolDefault("rendersWmlSelectsAsMenuCards", false);
_haveRendersWmlSelectsAsMenuCards = true;
}
return _rendersWmlSelectsAsMenuCards;
}
}
public virtual bool RendersBreaksAfterWmlAnchor {
get {
if (!_haveRendersBreaksAfterWmlAnchor) {
_rendersBreaksAfterWmlAnchor = CapsParseBoolDefault("rendersBreaksAfterWmlAnchor", true);
_haveRendersBreaksAfterWmlAnchor = true;
}
return _rendersBreaksAfterWmlAnchor;
}
}
public virtual bool RendersBreaksAfterWmlInput {
get {
if (!_haveRendersBreaksAfterWmlInput) {
_rendersBreaksAfterWmlInput = CapsParseBoolDefault("rendersBreaksAfterWmlInput", true);
_haveRendersBreaksAfterWmlInput = true;
}
return _rendersBreaksAfterWmlInput;
}
}
public virtual bool RendersBreakBeforeWmlSelectAndInput {
get {
if (!_haveRendersBreakBeforeWmlSelectAndInput) {
_rendersBreakBeforeWmlSelectAndInput = CapsParseBoolDefault("rendersBreakBeforeWmlSelectAndInput", false);
_haveRendersBreakBeforeWmlSelectAndInput = true;
}
return _rendersBreakBeforeWmlSelectAndInput;
}
}
public virtual bool RequiresPhoneNumbersAsPlainText {
get {
if (!_haveRequiresPhoneNumbersAsPlainText) {
_requiresPhoneNumbersAsPlainText = CapsParseBoolDefault("requiresPhoneNumbersAsPlainText", false);
_haveRequiresPhoneNumbersAsPlainText = true;
}
return _requiresPhoneNumbersAsPlainText;
}
}
public virtual bool RequiresUrlEncodedPostfieldValues {
get {
if (!_haveRequiresUrlEncodedPostfieldValues) {
_requiresUrlEncodedPostfieldValues = CapsParseBoolDefault("requiresUrlEncodedPostfieldValues", true);
_haveRequiresUrlEncodedPostfieldValues = true;
}
return _requiresUrlEncodedPostfieldValues;
}
}
public virtual String RequiredMetaTagNameValue {
get {
if (!_haveRequiredMetaTagNameValue) {
String value = this["requiredMetaTagNameValue"];
if (!String.IsNullOrEmpty(value)) {
_requiredMetaTagNameValue = value;
}
else {
_requiredMetaTagNameValue = null;
}
_haveRequiredMetaTagNameValue = true;
}
return _requiredMetaTagNameValue;
}
}
public virtual bool RendersBreaksAfterHtmlLists {
get {
if (!_haveRendersBreaksAfterHtmlLists) {
_rendersBreaksAfterHtmlLists = CapsParseBoolDefault("rendersBreaksAfterHtmlLists", true);
_haveRendersBreaksAfterHtmlLists = true;
}
return _rendersBreaksAfterHtmlLists;
}
}
public virtual bool RequiresUniqueHtmlInputNames {
get {
if (!_haveRequiresUniqueHtmlInputNames) {
_requiresUniqueHtmlInputNames = CapsParseBoolDefault("requiresUniqueHtmlInputNames", false);
_haveRequiresUniqueHtmlInputNames = true;
}
return _requiresUniqueHtmlInputNames;
}
}
public virtual bool RequiresUniqueHtmlCheckboxNames {
get {
if (!_haveRequiresUniqueHtmlCheckboxNames) {
_requiresUniqueHtmlCheckboxNames = CapsParseBoolDefault("requiresUniqueHtmlCheckboxNames", false);
_haveRequiresUniqueHtmlCheckboxNames = true;
}
return _requiresUniqueHtmlCheckboxNames;
}
}
public virtual bool SupportsCss {
get {
if (!_haveSupportsCss) {
_supportsCss = CapsParseBoolDefault("supportsCss", false);
_haveSupportsCss = true;
}
return _supportsCss;
}
}
public virtual bool HidesRightAlignedMultiselectScrollbars {
get {
if (!_haveHidesRightAlignedMultiselectScrollbars) {
_hidesRightAlignedMultiselectScrollbars = CapsParseBoolDefault("hidesRightAlignedMultiselectScrollbars", false);
_haveHidesRightAlignedMultiselectScrollbars = true;
}
return _hidesRightAlignedMultiselectScrollbars;
}
}
public virtual bool IsMobileDevice {
get {
if (!_haveIsMobileDevice) {
_isMobileDevice = CapsParseBoolDefault("isMobileDevice", false);
_haveIsMobileDevice = true;
}
return _isMobileDevice;
}
}
public virtual bool RequiresAttributeColonSubstitution {
get {
if (!_haveRequiresAttributeColonSubstitution) {
_requiresAttributeColonSubstitution = CapsParseBoolDefault("requiresAttributeColonSubstitution", false);
_haveRequiresAttributeColonSubstitution = true;
}
return _requiresAttributeColonSubstitution;
}
}
public virtual bool CanRenderOneventAndPrevElementsTogether {
get {
if (!_haveCanRenderOneventAndPrevElementsTogether) {
_canRenderOneventAndPrevElementsTogether = CapsParseBoolDefault("canRenderOneventAndPrevElementsTogether", true);
_haveCanRenderOneventAndPrevElementsTogether = true;
}
return _canRenderOneventAndPrevElementsTogether;
}
}
public virtual bool CanRenderInputAndSelectElementsTogether {
get {
if (!_haveCanRenderInputAndSelectElementsTogether) {
_canRenderInputAndSelectElementsTogether = CapsParseBoolDefault("canRenderInputAndSelectElementsTogether", true);
_haveCanRenderInputAndSelectElementsTogether = true;
}
return _canRenderInputAndSelectElementsTogether;
}
}
public virtual bool CanRenderAfterInputOrSelectElement {
get {
if (!_haveCanRenderAfterInputOrSelectElement) {
_canRenderAfterInputOrSelectElement = CapsParseBoolDefault("canRenderAfterInputOrSelectElement", true);
_haveCanRenderAfterInputOrSelectElement = true;
}
return _canRenderAfterInputOrSelectElement;
}
}
public virtual bool CanRenderPostBackCards {
get {
if (!_haveCanRenderPostBackCards) {
_canRenderPostBackCards = CapsParseBoolDefault("canRenderPostBackCards", true);
_haveCanRenderPostBackCards = true;
}
return _canRenderPostBackCards;
}
}
public virtual bool CanRenderMixedSelects {
get {
if (!_haveCanRenderMixedSelects) {
_canRenderMixedSelects = CapsParseBoolDefault("canRenderMixedSelects", true);
_haveCanRenderMixedSelects = true;
}
return _canRenderMixedSelects;
}
}
public virtual bool CanCombineFormsInDeck {
get {
if (!_haveCanCombineFormsInDeck) {
_canCombineFormsInDeck = CapsParseBoolDefault("canCombineFormsInDeck", true);
_haveCanCombineFormsInDeck = true;
}
return _canCombineFormsInDeck;
}
}
public virtual bool CanRenderSetvarZeroWithMultiSelectionList {
get {
if (!_haveCanRenderSetvarZeroWithMultiSelectionList) {
_canRenderSetvarZeroWithMultiSelectionList = CapsParseBoolDefault("canRenderSetvarZeroWithMultiSelectionList", true);
_haveCanRenderSetvarZeroWithMultiSelectionList = true;
}
return _canRenderSetvarZeroWithMultiSelectionList;
}
}
public virtual bool SupportsImageSubmit {
get {
if (!_haveSupportsImageSubmit) {
_supportsImageSubmit = CapsParseBoolDefault("supportsImageSubmit", false);
_haveSupportsImageSubmit = true;
}
return _supportsImageSubmit;
}
}
public virtual bool RequiresUniqueFilePathSuffix {
get {
if (!_haveRequiresUniqueFilePathSuffix) {
_requiresUniqueFilePathSuffix = CapsParseBoolDefault("requiresUniqueFilePathSuffix", false);
_haveRequiresUniqueFilePathSuffix = true;
}
return _requiresUniqueFilePathSuffix;
}
}
public virtual bool RequiresNoBreakInFormatting {
get {
if (!_haveRequiresNoBreakInFormatting) {
_requiresNoBreakInFormatting = CapsParseBoolDefault("requiresNoBreakInFormatting", false);
_haveRequiresNoBreakInFormatting = true;
}
return _requiresNoBreakInFormatting;
}
}
public virtual bool RequiresLeadingPageBreak {
get {
if (!_haveRequiresLeadingPageBreak) {
_requiresLeadingPageBreak = CapsParseBoolDefault("requiresLeadingPageBreak", false);
_haveRequiresLeadingPageBreak = true;
}
return _requiresLeadingPageBreak;
}
}
public virtual bool SupportsSelectMultiple {
get {
if (!_haveSupportsSelectMultiple) {
_supportsSelectMultiple = CapsParseBoolDefault("supportsSelectMultiple", false);
_haveSupportsSelectMultiple = true;
}
return _supportsSelectMultiple;
}
}
public /*new*/ virtual bool SupportsBold {
get {
if (!_haveSupportsBold) {
_supportsBold = CapsParseBoolDefault("supportsBold", true);
_haveSupportsBold = true;
}
return _supportsBold;
}
}
public /*new*/ virtual bool SupportsItalic {
get {
if (!_haveSupportsItalic) {
_supportsItalic = CapsParseBoolDefault("supportsItalic", true);
_haveSupportsItalic = true;
}
return _supportsItalic;
}
}
public virtual bool SupportsFontSize {
get {
if (!_haveSupportsFontSize) {
_supportsFontSize = CapsParseBoolDefault("supportsFontSize", false);
_haveSupportsFontSize = true;
}
return _supportsFontSize;
}
}
public virtual bool SupportsFontName {
get {
if (!_haveSupportsFontName) {
_supportsFontName = CapsParseBoolDefault("supportsFontName", false);
_haveSupportsFontName = true;
}
return _supportsFontName;
}
}
public virtual bool SupportsFontColor {
get {
if (!_haveSupportsFontColor) {
_supportsFontColor = CapsParseBoolDefault("supportsFontColor", false);
_haveSupportsFontColor = true;
}
return _supportsFontColor;
}
}
public virtual bool SupportsBodyColor {
get {
if (!_haveSupportsBodyColor) {
_supportsBodyColor = CapsParseBoolDefault("supportsBodyColor", false);
_haveSupportsBodyColor = true;
}
return _supportsBodyColor;
}
}
public virtual bool SupportsDivAlign {
get {
if (!_haveSupportsDivAlign) {
_supportsDivAlign = CapsParseBoolDefault("supportsDivAlign", false);
_haveSupportsDivAlign = true;
}
return _supportsDivAlign;
}
}
public virtual bool SupportsDivNoWrap {
get {
if (!_haveSupportsDivNoWrap) {
_supportsDivNoWrap = CapsParseBoolDefault("supportsDivNoWrap", false);
_haveSupportsDivNoWrap = true;
}
return _supportsDivNoWrap;
}
}
internal bool SupportsMaintainScrollPositionOnPostback {
get {
if (!_haveSupportsMaintainScrollPositionOnPostback) {
_supportsMaintainScrollPositionOnPostback = CapsParseBoolDefault("supportsMaintainScrollPositionOnPostback", false);
_haveSupportsMaintainScrollPositionOnPostback = true;
}
return _supportsMaintainScrollPositionOnPostback;
}
}
public virtual bool RequiresContentTypeMetaTag {
get {
if (!_haveRequiresContentTypeMetaTag) {
_requiresContentTypeMetaTag = CapsParseBoolDefault("requiresContentTypeMetaTag", false);
_haveRequiresContentTypeMetaTag = true;
}
return _requiresContentTypeMetaTag;
}
}
public virtual bool RequiresDBCSCharacter {
get {
if (!_haveRequiresDBCSCharacter) {
_requiresDBCSCharacter = CapsParseBoolDefault("requiresDBCSCharacter", false);
_haveRequiresDBCSCharacter = true;
}
return _requiresDBCSCharacter;
}
}
public virtual bool RequiresHtmlAdaptiveErrorReporting {
get {
if (!_haveRequiresHtmlAdaptiveErrorReporting) {
_requiresHtmlAdaptiveErrorReporting = CapsParseBoolDefault("requiresHtmlAdaptiveErrorReporting", false);
_haveRequiresHtmlAdaptiveErrorReporting = true;
}
return _requiresHtmlAdaptiveErrorReporting;
}
}
public virtual bool RequiresOutputOptimization {
get {
if (!_haveRequiresOutputOptimization) {
_requiresOutputOptimization = CapsParseBoolDefault("requiresOutputOptimization", false);
_haveRequiresOutputOptimization = true;
}
return _requiresOutputOptimization;
}
}
public virtual bool SupportsAccesskeyAttribute {
get {
if (!_haveSupportsAccesskeyAttribute) {
_supportsAccesskeyAttribute = CapsParseBoolDefault("supportsAccesskeyAttribute", false);
_haveSupportsAccesskeyAttribute = true;
}
return _supportsAccesskeyAttribute;
}
}
public virtual bool SupportsInputIStyle {
get {
if (!_haveSupportsInputIStyle) {
_supportsInputIStyle = CapsParseBoolDefault("supportsInputIStyle", false);
_haveSupportsInputIStyle = true;
}
return _supportsInputIStyle;
}
}
public virtual bool SupportsInputMode {
get {
if (!_haveSupportsInputMode) {
_supportsInputMode = CapsParseBoolDefault("supportsInputMode", false);
_haveSupportsInputMode = true;
}
return _supportsInputMode;
}
}
public virtual bool SupportsIModeSymbols {
get {
if (!_haveSupportsIModeSymbols) {
_supportsIModeSymbols = CapsParseBoolDefault("supportsIModeSymbols", false);
_haveSupportsIModeSymbols = true;
}
return _supportsIModeSymbols;
}
}
public virtual bool SupportsJPhoneSymbols {
get {
if (!_haveSupportsJPhoneSymbols) {
_supportsJPhoneSymbols = CapsParseBoolDefault("supportsJPhoneSymbols", false);
_haveSupportsJPhoneSymbols = true;
}
return _supportsJPhoneSymbols;
}
}
public virtual bool SupportsJPhoneMultiMediaAttributes {
get {
if (!_haveSupportsJPhoneMultiMediaAttributes) {
_supportsJPhoneMultiMediaAttributes = CapsParseBoolDefault("supportsJPhoneMultiMediaAttributes", false);
_haveSupportsJPhoneMultiMediaAttributes = true;
}
return _supportsJPhoneMultiMediaAttributes;
}
}
public virtual int MaximumRenderedPageSize {
get {
if (!_haveMaximumRenderedPageSize) {
_maximumRenderedPageSize = Convert.ToInt32(this["maximumRenderedPageSize"], CultureInfo.InvariantCulture);
_haveMaximumRenderedPageSize = true;
}
return _maximumRenderedPageSize;
}
}
public virtual bool RequiresSpecialViewStateEncoding {
get {
if (!_haveRequiresSpecialViewStateEncoding) {
_requiresSpecialViewStateEncoding = CapsParseBoolDefault("requiresSpecialViewStateEncoding", false);
_haveRequiresSpecialViewStateEncoding = true;
}
return _requiresSpecialViewStateEncoding;
}
}
public virtual bool SupportsQueryStringInFormAction {
get {
if (!_haveSupportsQueryStringInFormAction) {
_supportsQueryStringInFormAction = CapsParseBoolDefault("supportsQueryStringInFormAction", true);
_haveSupportsQueryStringInFormAction = true;
}
return _supportsQueryStringInFormAction;
}
}
public virtual bool SupportsCacheControlMetaTag {
get {
if (!_haveSupportsCacheControlMetaTag) {
_supportsCacheControlMetaTag = CapsParseBoolDefault("supportsCacheControlMetaTag", true);
_haveSupportsCacheControlMetaTag = true;
}
return _supportsCacheControlMetaTag;
}
}
public virtual bool SupportsUncheck {
get {
if (!_haveSupportsUncheck) {
_supportsUncheck = CapsParseBoolDefault("supportsUncheck", true);
_haveSupportsUncheck = true;
}
return _supportsUncheck;
}
}
public virtual bool CanRenderEmptySelects {
get {
if (!_haveCanRenderEmptySelects) {
_canRenderEmptySelects = CapsParseBoolDefault("canRenderEmptySelects", true);
_haveCanRenderEmptySelects = true;
}
return _canRenderEmptySelects;
}
}
public virtual bool SupportsRedirectWithCookie {
get {
if (!_haveSupportsRedirectWithCookie) {
_supportsRedirectWithCookie = CapsParseBoolDefault("supportsRedirectWithCookie", true);
_haveSupportsRedirectWithCookie = true;
}
return _supportsRedirectWithCookie;
}
}
public virtual bool SupportsEmptyStringInCookieValue {
get {
if (!_haveSupportsEmptyStringInCookieValue) {
_supportsEmptyStringInCookieValue = CapsParseBoolDefault("supportsEmptyStringInCookieValue", true);
_haveSupportsEmptyStringInCookieValue = true;
}
return _supportsEmptyStringInCookieValue;
}
}
public virtual int DefaultSubmitButtonLimit {
get {
if (!_haveDefaultSubmitButtonLimit) {
String s = this["defaultSubmitButtonLimit"];
_defaultSubmitButtonLimit = s != null ? Convert.ToInt32(this["defaultSubmitButtonLimit"], CultureInfo.InvariantCulture) : 1;
_haveDefaultSubmitButtonLimit = true;
}
return _defaultSubmitButtonLimit;
}
}
public virtual bool SupportsXmlHttp {
get {
if (!_haveSupportsXmlHttp) {
_supportsXmlHttp = CapsParseBoolDefault("supportsXmlHttp", false);
_haveSupportsXmlHttp = true;
}
return _supportsXmlHttp;
}
}
public virtual bool SupportsCallback {
get {
if (!_haveSupportsCallback) {
_supportsCallback = CapsParseBoolDefault("supportsCallback", false);
_haveSupportsCallback = true;
}
return _supportsCallback;
}
}
public virtual int MaximumHrefLength {
get {
if (!_haveMaximumHrefLength) {
_maximumHrefLength = Convert.ToInt32(this["maximumHrefLength"], CultureInfo.InvariantCulture);
_haveMaximumHrefLength = true;
}
return _maximumHrefLength;
}
}
public bool IsBrowser(string browserName) {
if (String.IsNullOrEmpty(browserName)) {
return false;
}
if (_browsers == null) {
return false;
}
for (int i = 0; i < _browsers.Count; i++) {
if (String.Equals(browserName, (string)_browsers[i], StringComparison.OrdinalIgnoreCase)) {
return true;
}
}
return false;
}
public void AddBrowser(string browserName) {
if (_browsers == null) {
lock (_staticLock) {
if (_browsers == null) {
_browsers = new ArrayList(6);
}
}
}
_browsers.Add(browserName.ToLower(CultureInfo.InvariantCulture));
}
private ArrayList _browsers;
volatile private string _type;
volatile private string _browser;
volatile private string _version;
volatile private int _majorversion;
private double _minorversion;
volatile private string _platform;
volatile private Type _tagwriter;
volatile private Version _ecmascriptversion;
volatile private Version _jscriptversion;
volatile private Version _msdomversion;
volatile private Version _w3cdomversion;
volatile private bool _beta;
volatile private bool _crawler;
volatile private bool _aol;
volatile private bool _win16;
volatile private bool _win32;
volatile private bool _requiresControlStateInSession;
volatile private bool _frames;
//private bool _supportsbold;
//private bool _supportsitalic;
volatile private bool _tables;
volatile private bool _cookies;
volatile private bool _vbscript;
volatile private bool _javascript;
volatile private bool _javaapplets;
volatile private bool _activexcontrols;
volatile private bool _backgroundsounds;
volatile private bool _cdf;
volatile private bool _havetype;
volatile private bool _havebrowser;
volatile private bool _haveversion;
volatile private bool _havemajorversion;
volatile private bool _haveminorversion;
volatile private bool _haveplatform;
volatile private bool _havetagwriter;
volatile private bool _haveecmascriptversion;
volatile private bool _havemsdomversion;
volatile private bool _havew3cdomversion;
volatile private bool _havebeta;
volatile private bool _havecrawler;
volatile private bool _haveaol;
volatile private bool _havewin16;
volatile private bool _havewin32;
volatile private bool _haveframes;
volatile private bool _haverequiresControlStateInSession;
//private bool _havesupportsbold;
//private bool _havesupportsitalic;
volatile private bool _havetables;
volatile private bool _havecookies;
volatile private bool _havevbscript;
volatile private bool _havejavascript;
volatile private bool _havejavaapplets;
volatile private bool _haveactivexcontrols;
volatile private bool _havebackgroundsounds;
volatile private bool _havecdf;
//previously in System.Web.Mobile
volatile private String _mobileDeviceManufacturer;
volatile private String _mobileDeviceModel;
volatile private String _gatewayVersion;
volatile private int _gatewayMajorVersion;
private double _gatewayMinorVersion;
volatile private String _preferredRenderingType; //
volatile private String _preferredRenderingMime;
volatile private String _preferredImageMime;
volatile private String _requiredMetaTagNameValue;
volatile private String _preferredRequestEncoding;
volatile private String _preferredResponseEncoding;
volatile private int _screenCharactersWidth;
volatile private int _screenCharactersHeight;
volatile private int _screenPixelsWidth;
volatile private int _screenPixelsHeight;
volatile private int _screenBitDepth;
volatile private bool _isColor;
volatile private String _inputType;
volatile private int _numberOfSoftkeys;
volatile private int _maximumSoftkeyLabelLength;
volatile private bool _canInitiateVoiceCall;
volatile private bool _canSendMail;
volatile private bool _hasBackButton;
volatile private bool _rendersWmlDoAcceptsInline;
volatile private bool _rendersWmlSelectsAsMenuCards;
volatile private bool _rendersBreaksAfterWmlAnchor;
volatile private bool _rendersBreaksAfterWmlInput;
volatile private bool _rendersBreakBeforeWmlSelectAndInput;
volatile private bool _requiresPhoneNumbersAsPlainText;
volatile private bool _requiresAttributeColonSubstitution;
volatile private bool _requiresUrlEncodedPostfieldValues;
volatile private bool _rendersBreaksAfterHtmlLists;
volatile private bool _requiresUniqueHtmlCheckboxNames;
volatile private bool _requiresUniqueHtmlInputNames;
volatile private bool _supportsCss;
volatile private bool _hidesRightAlignedMultiselectScrollbars;
volatile private bool _isMobileDevice;
volatile private bool _canRenderOneventAndPrevElementsTogether;
volatile private bool _canRenderInputAndSelectElementsTogether;
volatile private bool _canRenderAfterInputOrSelectElement;
volatile private bool _canRenderPostBackCards;
volatile private bool _canRenderMixedSelects;
volatile private bool _canCombineFormsInDeck;
volatile private bool _canRenderSetvarZeroWithMultiSelectionList;
volatile private bool _supportsImageSubmit;
volatile private bool _requiresUniqueFilePathSuffix;
volatile private bool _requiresNoBreakInFormatting;
volatile private bool _requiresLeadingPageBreak;
volatile private bool _supportsSelectMultiple;
volatile private bool _supportsBold;
volatile private bool _supportsItalic;
volatile private bool _supportsFontSize;
volatile private bool _supportsFontName;
volatile private bool _supportsFontColor;
volatile private bool _supportsBodyColor;
volatile private bool _supportsDivAlign;
volatile private bool _supportsDivNoWrap;
volatile private bool _requiresHtmlAdaptiveErrorReporting;
volatile private bool _requiresContentTypeMetaTag;
volatile private bool _requiresDBCSCharacter;
volatile private bool _requiresOutputOptimization;
volatile private bool _supportsAccesskeyAttribute;
volatile private bool _supportsInputIStyle;
volatile private bool _supportsInputMode;
volatile private bool _supportsIModeSymbols;
volatile private bool _supportsJPhoneSymbols;
volatile private bool _supportsJPhoneMultiMediaAttributes;
volatile private int _maximumRenderedPageSize;
volatile private bool _requiresSpecialViewStateEncoding;
volatile private bool _supportsQueryStringInFormAction;
volatile private bool _supportsCacheControlMetaTag;
volatile private bool _supportsUncheck;
volatile private bool _canRenderEmptySelects;
volatile private bool _supportsRedirectWithCookie;
volatile private bool _supportsEmptyStringInCookieValue;
volatile private int _defaultSubmitButtonLimit;
volatile private bool _supportsXmlHttp;
volatile private bool _supportsCallback;
volatile private bool _supportsMaintainScrollPositionOnPostback;
volatile private int _maximumHrefLength;
volatile private bool _haveMobileDeviceManufacturer;
volatile private bool _haveMobileDeviceModel;
volatile private bool _haveGatewayVersion;
volatile private bool _haveGatewayMajorVersion;
volatile private bool _haveGatewayMinorVersion;
volatile private bool _havePreferredRenderingType;
volatile private bool _havePreferredRenderingMime;
volatile private bool _havePreferredImageMime;
volatile private bool _havePreferredRequestEncoding;
volatile private bool _havePreferredResponseEncoding;
volatile private bool _haveScreenCharactersWidth;
volatile private bool _haveScreenCharactersHeight;
volatile private bool _haveScreenPixelsWidth;
volatile private bool _haveScreenPixelsHeight;
volatile private bool _haveScreenBitDepth;
volatile private bool _haveIsColor;
volatile private bool _haveInputType;
volatile private bool _haveNumberOfSoftkeys;
volatile private bool _haveMaximumSoftkeyLabelLength;
volatile private bool _haveCanInitiateVoiceCall;
volatile private bool _haveCanSendMail;
volatile private bool _haveHasBackButton;
volatile private bool _haveRendersWmlDoAcceptsInline;
volatile private bool _haveRendersWmlSelectsAsMenuCards;
volatile private bool _haveRendersBreaksAfterWmlAnchor;
volatile private bool _haveRendersBreaksAfterWmlInput;
volatile private bool _haveRendersBreakBeforeWmlSelectAndInput;
volatile private bool _haveRequiresPhoneNumbersAsPlainText;
volatile private bool _haveRequiresUrlEncodedPostfieldValues;
volatile private bool _haveRequiredMetaTagNameValue;
volatile private bool _haveRendersBreaksAfterHtmlLists;
volatile private bool _haveRequiresUniqueHtmlCheckboxNames;
volatile private bool _haveRequiresUniqueHtmlInputNames;
volatile private bool _haveSupportsCss;
volatile private bool _haveHidesRightAlignedMultiselectScrollbars;
volatile private bool _haveIsMobileDevice;
volatile private bool _haveCanRenderOneventAndPrevElementsTogether;
volatile private bool _haveCanRenderInputAndSelectElementsTogether;
volatile private bool _haveCanRenderAfterInputOrSelectElement;
volatile private bool _haveCanRenderPostBackCards;
volatile private bool _haveCanCombineFormsInDeck;
volatile private bool _haveCanRenderMixedSelects;
volatile private bool _haveCanRenderSetvarZeroWithMultiSelectionList;
volatile private bool _haveSupportsImageSubmit;
volatile private bool _haveRequiresUniqueFilePathSuffix;
volatile private bool _haveRequiresNoBreakInFormatting;
volatile private bool _haveRequiresLeadingPageBreak;
volatile private bool _haveSupportsSelectMultiple;
volatile private bool _haveRequiresAttributeColonSubstitution;
volatile private bool _haveRequiresHtmlAdaptiveErrorReporting;
volatile private bool _haveRequiresContentTypeMetaTag;
volatile private bool _haveRequiresDBCSCharacter;
volatile private bool _haveRequiresOutputOptimization;
volatile private bool _haveSupportsAccesskeyAttribute;
volatile private bool _haveSupportsInputIStyle;
volatile private bool _haveSupportsInputMode;
volatile private bool _haveSupportsIModeSymbols;
volatile private bool _haveSupportsJPhoneSymbols;
volatile private bool _haveSupportsJPhoneMultiMediaAttributes;
volatile private bool _haveSupportsRedirectWithCookie;
volatile private bool _haveSupportsEmptyStringInCookieValue = false;
volatile private bool _haveSupportsBold;
volatile private bool _haveSupportsItalic;
volatile private bool _haveSupportsFontSize;
volatile private bool _haveSupportsFontName;
volatile private bool _haveSupportsFontColor;
volatile private bool _haveSupportsBodyColor;
volatile private bool _haveSupportsDivAlign;
volatile private bool _haveSupportsDivNoWrap;
volatile private bool _haveMaximumRenderedPageSize;
volatile private bool _haveRequiresSpecialViewStateEncoding;
volatile private bool _haveSupportsQueryStringInFormAction;
volatile private bool _haveSupportsCacheControlMetaTag;
volatile private bool _haveSupportsUncheck;
volatile private bool _haveCanRenderEmptySelects;
volatile private bool _haveDefaultSubmitButtonLimit;
volatile private bool _haveSupportsXmlHttp;
volatile private bool _haveSupportsCallback;
volatile private bool _haveSupportsMaintainScrollPositionOnPostback;
volatile private bool _haveMaximumHrefLength;
volatile private bool _havejscriptversion;
#region IFilterResolutionService implementation
/// <internalonly/>
bool IFilterResolutionService.EvaluateFilter(string filterName) {
return IsBrowser(filterName);
}
/// <internalonly/>
int IFilterResolutionService.CompareFilters(string filter1, string filter2) {
return BrowserCapabilitiesCompiler.BrowserCapabilitiesFactory.CompareFilters(filter1, filter2);
}
#endregion
}
}
|