TemplateParser.cs 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450
  1. //
  2. // System.Web.UI.TemplateParser
  3. //
  4. // Authors:
  5. // Duncan Mak ([email protected])
  6. // Gonzalo Paniagua Javier ([email protected])
  7. // Marek Habersack ([email protected])
  8. //
  9. // (C) 2002,2003 Ximian, Inc. (http://www.ximian.com)
  10. // Copyright (C) 2005-2008 Novell, Inc (http://www.novell.com)
  11. //
  12. // Permission is hereby granted, free of charge, to any person obtaining
  13. // a copy of this software and associated documentation files (the
  14. // "Software"), to deal in the Software without restriction, including
  15. // without limitation the rights to use, copy, modify, merge, publish,
  16. // distribute, sublicense, and/or sell copies of the Software, and to
  17. // permit persons to whom the Software is furnished to do so, subject to
  18. // the following conditions:
  19. //
  20. // The above copyright notice and this permission notice shall be
  21. // included in all copies or substantial portions of the Software.
  22. //
  23. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  27. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  28. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  29. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. //
  31. using System.CodeDom.Compiler;
  32. using System.Collections;
  33. using System.ComponentModel;
  34. using System.Globalization;
  35. using System.IO;
  36. using System.Reflection;
  37. using System.Security.Permissions;
  38. using System.Text;
  39. using System.Threading;
  40. using System.Web.Compilation;
  41. using System.Web.Configuration;
  42. using System.Web.Hosting;
  43. using System.Web.Util;
  44. #if NET_2_0
  45. using System.Collections.Generic;
  46. #endif
  47. namespace System.Web.UI {
  48. internal class ServerSideScript
  49. {
  50. public readonly string Script;
  51. public readonly ILocation Location;
  52. public ServerSideScript (string script, ILocation location)
  53. {
  54. Script = script;
  55. Location = location;
  56. }
  57. }
  58. // CAS
  59. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  60. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  61. public abstract class TemplateParser : BaseParser
  62. {
  63. #if NET_2_0
  64. [Flags]
  65. internal enum OutputCacheParsedParams
  66. {
  67. Location = 0x0001,
  68. CacheProfile = 0x0002,
  69. NoStore = 0x0004,
  70. SqlDependency = 0x0008,
  71. VaryByCustom = 0x0010,
  72. VaryByHeader = 0x0020,
  73. VaryByControl = 0x0040,
  74. VaryByContentEncodings = 0x0080
  75. }
  76. #endif
  77. string inputFile;
  78. string text;
  79. Hashtable mainAttributes;
  80. ArrayList dependencies;
  81. ArrayList assemblies;
  82. Hashtable anames;
  83. #if NET_2_0
  84. string[] binDirAssemblies;
  85. Dictionary <string, bool> namespacesCache;
  86. List <string> imports;
  87. List <string> interfaces;
  88. List <ServerSideScript> scripts;
  89. #else
  90. ArrayList imports;
  91. ArrayList interfaces;
  92. ArrayList scripts;
  93. #endif
  94. Type baseType;
  95. bool baseTypeIsGlobal = true;
  96. string className;
  97. RootBuilder rootBuilder;
  98. bool debug;
  99. string compilerOptions;
  100. string language;
  101. bool implicitLanguage;
  102. bool strictOn ;
  103. bool explicitOn;
  104. bool linePragmasOn = true;
  105. bool output_cache;
  106. int oc_duration;
  107. string oc_header, oc_custom, oc_param, oc_controls;
  108. #if NET_2_0
  109. string oc_content_encodings, oc_cacheprofile, oc_sqldependency;
  110. bool oc_nostore;
  111. OutputCacheParsedParams oc_parsed_params = 0;
  112. #endif
  113. bool oc_shared;
  114. OutputCacheLocation oc_location;
  115. CultureInfo invariantCulture = CultureInfo.InvariantCulture;
  116. #if NET_2_0
  117. // Kludge needed to support pre-parsing of the main directive (see
  118. // AspNetGenerator.GetRootBuilderType)
  119. internal int allowedMainDirectives = 0;
  120. byte[] md5checksum;
  121. string src;
  122. bool srcIsLegacy;
  123. string partialClassName;
  124. string codeFileBaseClass;
  125. string metaResourceKey;
  126. Type codeFileBaseClassType;
  127. Type pageParserFilterType;
  128. PageParserFilter pageParserFilter;
  129. List <UnknownAttributeDescriptor> unknownMainAttributes;
  130. Stack <string> includeDirs;
  131. List <string> registeredTagNames;
  132. #else
  133. Stack includeDirs;
  134. Assembly srcAssembly;
  135. #endif
  136. ILocation directiveLocation;
  137. int appAssemblyIndex = -1;
  138. internal TemplateParser ()
  139. {
  140. LoadConfigDefaults ();
  141. #if NET_2_0
  142. imports = new List <string> ();
  143. AddNamespaces (imports);
  144. #else
  145. imports = new ArrayList ();
  146. imports.Add ("System");
  147. imports.Add ("System.Collections");
  148. imports.Add ("System.Collections.Specialized");
  149. imports.Add ("System.Configuration");
  150. imports.Add ("System.Text");
  151. imports.Add ("System.Text.RegularExpressions");
  152. imports.Add ("System.Web");
  153. imports.Add ("System.Web.Caching");
  154. imports.Add ("System.Web.Security");
  155. imports.Add ("System.Web.SessionState");
  156. imports.Add ("System.Web.UI");
  157. imports.Add ("System.Web.UI.WebControls");
  158. imports.Add ("System.Web.UI.HtmlControls");
  159. #endif
  160. assemblies = new ArrayList ();
  161. #if NET_2_0
  162. CompilationSection compConfig = CompilationConfig;
  163. foreach (AssemblyInfo info in compConfig.Assemblies) {
  164. if (info.Assembly != "*")
  165. AddAssemblyByName (info.Assembly);
  166. }
  167. foreach (NamespaceInfo info in PagesConfig.Namespaces) {
  168. imports.Add (info.Namespace);
  169. }
  170. #else
  171. CompilationConfiguration compConfig = CompilationConfig;
  172. foreach (string a in compConfig.Assemblies)
  173. AddAssemblyByName (a);
  174. if (compConfig.AssembliesInBin)
  175. AddAssembliesInBin ();
  176. #endif
  177. language = compConfig.DefaultLanguage;
  178. implicitLanguage = true;
  179. }
  180. internal virtual void LoadConfigDefaults ()
  181. {
  182. debug = CompilationConfig.Debug;
  183. }
  184. internal void AddApplicationAssembly ()
  185. {
  186. if (Context.ApplicationInstance == null)
  187. return; // this may happen if we have Global.asax and have
  188. // controls registered from Web.Config
  189. string location = Context.ApplicationInstance.AssemblyLocation;
  190. if (location != typeof (TemplateParser).Assembly.Location) {
  191. appAssemblyIndex = assemblies.Add (location);
  192. }
  193. }
  194. protected abstract Type CompileIntoType ();
  195. #if NET_2_0
  196. internal void AddControl (Type type, IDictionary attributes)
  197. {
  198. AspGenerator generator = AspGenerator;
  199. if (generator == null)
  200. return;
  201. generator.AddControl (type, attributes);
  202. }
  203. void AddNamespaces (List <string> imports)
  204. {
  205. if (BuildManager.HaveResources)
  206. imports.Add ("System.Resources");
  207. PagesSection pages = PagesConfig;
  208. if (pages == null)
  209. return;
  210. NamespaceCollection namespaces = pages.Namespaces;
  211. if (namespaces == null || namespaces.Count == 0)
  212. return;
  213. foreach (NamespaceInfo nsi in namespaces)
  214. imports.Add (nsi.Namespace);
  215. }
  216. #endif
  217. internal void RegisterCustomControl (string tagPrefix, string tagName, string src)
  218. {
  219. string realpath = null;
  220. bool fileExists = false;
  221. #if NET_2_0
  222. VirtualFile vf = null;
  223. VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
  224. VirtualPath vp = new VirtualPath (src, BaseVirtualDir);
  225. string vpAbsolute = vp.Absolute;
  226. if (vpp.FileExists (vpAbsolute)) {
  227. fileExists = true;
  228. vf = vpp.GetFile (vpAbsolute);
  229. if (vf != null)
  230. realpath = MapPath (vf.VirtualPath);
  231. }
  232. #else
  233. realpath = MapPath (src);
  234. fileExists = File.Exists (realpath);
  235. #endif
  236. if (!fileExists)
  237. ThrowParseFileNotFound (src);
  238. if (String.Compare (realpath, inputFile, false, invariantCulture) == 0)
  239. return;
  240. #if NET_2_0
  241. string vpath = vf.VirtualPath;
  242. #else
  243. string vpath = VirtualPathUtility.Combine (BaseVirtualDir, src);
  244. if (VirtualPathUtility.IsAbsolute (vpath))
  245. vpath = VirtualPathUtility.ToAppRelative (vpath);
  246. #endif
  247. try {
  248. #if NET_2_0
  249. RegisterTagName (tagPrefix + ":" + tagName);
  250. RootBuilder.Foundry.RegisterFoundry (tagPrefix, tagName, vpath);
  251. #else
  252. Type type = null;
  253. ArrayList other_deps = new ArrayList ();
  254. type = UserControlParser.GetCompiledType (vpath, realpath, other_deps, Context);
  255. foreach (string s in other_deps)
  256. AddDependency (s);
  257. AddAssembly (type.Assembly, true);
  258. RootBuilder.Foundry.RegisterFoundry (tagPrefix, tagName, type);
  259. #endif
  260. AddDependency (vpath);
  261. } catch (ParseException pe) {
  262. if (this is UserControlParser)
  263. throw new ParseException (Location, pe.Message, pe);
  264. throw;
  265. }
  266. }
  267. internal void RegisterNamespace (string tagPrefix, string ns, string assembly)
  268. {
  269. AddImport (ns);
  270. Assembly ass = null;
  271. if (assembly != null && assembly.Length > 0)
  272. ass = AddAssemblyByName (assembly);
  273. RootBuilder.Foundry.RegisterFoundry (tagPrefix, ass, ns);
  274. }
  275. internal virtual void HandleOptions (object obj)
  276. {
  277. }
  278. internal static string GetOneKey (Hashtable tbl)
  279. {
  280. foreach (object key in tbl.Keys)
  281. return key.ToString ();
  282. return null;
  283. }
  284. internal virtual void AddDirective (string directive, Hashtable atts)
  285. {
  286. #if NET_2_0
  287. var pageParserFilter = PageParserFilter;
  288. #endif
  289. if (String.Compare (directive, DefaultDirectiveName, true) == 0) {
  290. #if NET_2_0
  291. bool allowMainDirective = allowedMainDirectives > 0;
  292. #else
  293. bool allowMainDirective = false;
  294. #endif
  295. if (mainAttributes != null && !allowMainDirective)
  296. ThrowParseException ("Only 1 " + DefaultDirectiveName + " is allowed");
  297. #if NET_2_0
  298. allowedMainDirectives--;
  299. if (mainAttributes != null)
  300. return;
  301. if (pageParserFilter != null)
  302. pageParserFilter.PreprocessDirective (directive.ToLower (CultureInfo.InvariantCulture), atts);
  303. #endif
  304. mainAttributes = atts;
  305. ProcessMainAttributes (mainAttributes);
  306. return;
  307. }
  308. #if NET_2_0
  309. else if (pageParserFilter != null)
  310. pageParserFilter.PreprocessDirective (directive.ToLower (CultureInfo.InvariantCulture), atts);
  311. #endif
  312. int cmp = String.Compare ("Assembly", directive, true);
  313. if (cmp == 0) {
  314. string name = GetString (atts, "Name", null);
  315. string src = GetString (atts, "Src", null);
  316. if (atts.Count > 0)
  317. ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown.");
  318. if (name == null && src == null)
  319. ThrowParseException ("You gotta specify Src or Name");
  320. if (name != null && src != null)
  321. ThrowParseException ("Src and Name cannot be used together");
  322. if (name != null) {
  323. AddAssemblyByName (name);
  324. } else {
  325. GetAssemblyFromSource (src);
  326. }
  327. return;
  328. }
  329. cmp = String.Compare ("Import", directive, true);
  330. if (cmp == 0) {
  331. string namesp = GetString (atts, "Namespace", null);
  332. if (atts.Count > 0)
  333. ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown.");
  334. AddImport (namesp);
  335. return;
  336. }
  337. cmp = String.Compare ("Implements", directive, true);
  338. if (cmp == 0) {
  339. string ifacename = GetString (atts, "Interface", "");
  340. if (atts.Count > 0)
  341. ThrowParseException ("Attribute " + GetOneKey (atts) + " unknown.");
  342. Type iface = LoadType (ifacename);
  343. if (iface == null)
  344. ThrowParseException ("Cannot find type " + ifacename);
  345. if (!iface.IsInterface)
  346. ThrowParseException (iface + " is not an interface");
  347. AddInterface (iface.FullName);
  348. return;
  349. }
  350. cmp = String.Compare ("OutputCache", directive, true);
  351. if (cmp == 0) {
  352. HttpResponse response = HttpContext.Current.Response;
  353. if (response != null)
  354. response.Cache.SetValidUntilExpires (true);
  355. output_cache = true;
  356. if (atts ["Duration"] == null)
  357. ThrowParseException ("The directive is missing a 'duration' attribute.");
  358. if (atts ["VaryByParam"] == null && atts ["VaryByControl"] == null)
  359. ThrowParseException ("This directive is missing 'VaryByParam' " +
  360. "or 'VaryByControl' attribute, which should be set to \"none\", \"*\", " +
  361. "or a list of name/value pairs.");
  362. foreach (DictionaryEntry entry in atts) {
  363. string key = (string) entry.Key;
  364. switch (key.ToLower ()) {
  365. case "duration":
  366. oc_duration = Int32.Parse ((string) entry.Value);
  367. if (oc_duration < 1)
  368. ThrowParseException ("The 'duration' attribute must be set " +
  369. "to a positive integer value");
  370. break;
  371. #if NET_2_0
  372. case "sqldependency":
  373. oc_sqldependency = (string) entry.Value;
  374. break;
  375. case "nostore":
  376. try {
  377. oc_nostore = Boolean.Parse ((string) entry.Value);
  378. oc_parsed_params |= OutputCacheParsedParams.NoStore;
  379. } catch {
  380. ThrowParseException ("The 'NoStore' attribute is case sensitive" +
  381. " and must be set to 'true' or 'false'.");
  382. }
  383. break;
  384. case "cacheprofile":
  385. oc_cacheprofile = (string) entry.Value;
  386. oc_parsed_params |= OutputCacheParsedParams.CacheProfile;
  387. break;
  388. case "varybycontentencodings":
  389. oc_content_encodings = (string) entry.Value;
  390. oc_parsed_params |= OutputCacheParsedParams.VaryByContentEncodings;
  391. break;
  392. #endif
  393. case "varybyparam":
  394. oc_param = (string) entry.Value;
  395. if (String.Compare (oc_param, "none") == 0)
  396. oc_param = null;
  397. break;
  398. case "varybyheader":
  399. oc_header = (string) entry.Value;
  400. #if NET_2_0
  401. oc_parsed_params |= OutputCacheParsedParams.VaryByHeader;
  402. #endif
  403. break;
  404. case "varybycustom":
  405. oc_custom = (string) entry.Value;
  406. #if NET_2_0
  407. oc_parsed_params |= OutputCacheParsedParams.VaryByCustom;
  408. #endif
  409. break;
  410. case "location":
  411. if (!(this is PageParser))
  412. goto default;
  413. try {
  414. oc_location = (OutputCacheLocation) Enum.Parse (
  415. typeof (OutputCacheLocation), (string) entry.Value, true);
  416. #if NET_2_0
  417. oc_parsed_params |= OutputCacheParsedParams.Location;
  418. #endif
  419. } catch {
  420. ThrowParseException ("The 'location' attribute is case sensitive and " +
  421. "must be one of the following values: Any, Client, " +
  422. "Downstream, Server, None, ServerAndClient.");
  423. }
  424. break;
  425. case "varybycontrol":
  426. #if ONLY_1_1
  427. if (this is PageParser)
  428. goto default;
  429. #endif
  430. oc_controls = (string) entry.Value;
  431. #if NET_2_0
  432. oc_parsed_params |= OutputCacheParsedParams.VaryByControl;
  433. #endif
  434. break;
  435. case "shared":
  436. if (this is PageParser)
  437. goto default;
  438. try {
  439. oc_shared = Boolean.Parse ((string) entry.Value);
  440. } catch {
  441. ThrowParseException ("The 'shared' attribute is case sensitive" +
  442. " and must be set to 'true' or 'false'.");
  443. }
  444. break;
  445. default:
  446. ThrowParseException ("The '" + key + "' attribute is not " +
  447. "supported by the 'Outputcache' directive.");
  448. break;
  449. }
  450. }
  451. return;
  452. }
  453. ThrowParseException ("Unknown directive: " + directive);
  454. }
  455. internal Type LoadType (string typeName)
  456. {
  457. Type type = HttpApplication.LoadType (typeName);
  458. if (type == null)
  459. return null;
  460. Assembly asm = type.Assembly;
  461. string location = asm.Location;
  462. string dirname = Path.GetDirectoryName (location);
  463. bool doAddAssembly = true;
  464. if (dirname == HttpApplication.BinDirectory)
  465. doAddAssembly = false;
  466. if (doAddAssembly)
  467. AddAssembly (asm, true);
  468. return type;
  469. }
  470. void AddAssembliesInBin ()
  471. {
  472. foreach (string s in HttpApplication.BinDirectoryAssemblies)
  473. assemblies.Add (s);
  474. }
  475. internal virtual void AddInterface (string iface)
  476. {
  477. if (interfaces == null) {
  478. #if NET_2_0
  479. interfaces = new List <string> ();
  480. #else
  481. interfaces = new ArrayList ();
  482. #endif
  483. }
  484. if (!interfaces.Contains (iface))
  485. interfaces.Add (iface);
  486. }
  487. internal virtual void AddImport (string namesp)
  488. {
  489. if (namesp == null || namesp.Length == 0)
  490. return;
  491. if (imports == null) {
  492. #if NET_2_0
  493. imports = new List <string> ();
  494. #else
  495. imports = new ArrayList ();
  496. #endif
  497. }
  498. if (imports.Contains (namesp))
  499. return;
  500. imports.Add (namesp);
  501. #if NET_2_0
  502. AddAssemblyForNamespace (namesp);
  503. #endif
  504. }
  505. #if NET_2_0
  506. void AddAssemblyForNamespace (string namesp)
  507. {
  508. if (binDirAssemblies == null)
  509. binDirAssemblies = HttpApplication.BinDirectoryAssemblies;
  510. if (binDirAssemblies.Length == 0)
  511. return;
  512. if (namespacesCache == null)
  513. namespacesCache = new Dictionary <string, bool> ();
  514. else if (namespacesCache.ContainsKey (namesp))
  515. return;
  516. foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies ())
  517. if (FindNamespaceInAssembly (asm, namesp))
  518. return;
  519. IList tla = BuildManager.TopLevelAssemblies;
  520. if (tla != null && tla.Count > 0) {
  521. foreach (Assembly asm in tla) {
  522. if (FindNamespaceInAssembly (asm, namesp))
  523. return;
  524. }
  525. }
  526. Assembly a;
  527. foreach (string s in binDirAssemblies) {
  528. a = Assembly.LoadFrom (s);
  529. if (FindNamespaceInAssembly (a, namesp))
  530. return;
  531. }
  532. }
  533. bool FindNamespaceInAssembly (Assembly asm, string namesp)
  534. {
  535. foreach (Type type in asm.GetTypes ()) {
  536. if (String.Compare (type.Namespace, namesp, StringComparison.Ordinal) == 0) {
  537. namespacesCache.Add (namesp, true);
  538. AddAssembly (asm, true);
  539. return true;
  540. }
  541. }
  542. return false;
  543. }
  544. #endif
  545. internal virtual void AddSourceDependency (string filename)
  546. {
  547. if (dependencies != null && dependencies.Contains (filename))
  548. ThrowParseException ("Circular file references are not allowed. File: " + filename);
  549. AddDependency (filename);
  550. }
  551. internal virtual void AddDependency (string filename)
  552. {
  553. if (filename == null || filename == String.Empty)
  554. return;
  555. if (dependencies == null)
  556. dependencies = new ArrayList ();
  557. if (!dependencies.Contains (filename))
  558. dependencies.Add (filename);
  559. }
  560. internal virtual void AddAssembly (Assembly assembly, bool fullPath)
  561. {
  562. if (assembly == null || assembly.Location == String.Empty)
  563. return;
  564. if (anames == null)
  565. anames = new Hashtable ();
  566. string name = assembly.GetName ().Name;
  567. string loc = assembly.Location;
  568. if (fullPath) {
  569. if (!assemblies.Contains (loc)) {
  570. assemblies.Add (loc);
  571. }
  572. anames [name] = loc;
  573. anames [loc] = assembly;
  574. } else {
  575. if (!assemblies.Contains (name)) {
  576. assemblies.Add (name);
  577. }
  578. anames [name] = assembly;
  579. }
  580. }
  581. internal virtual Assembly AddAssemblyByFileName (string filename)
  582. {
  583. Assembly assembly = null;
  584. Exception error = null;
  585. try {
  586. assembly = Assembly.LoadFrom (filename);
  587. } catch (Exception e) { error = e; }
  588. if (assembly == null)
  589. ThrowParseException ("Assembly " + filename + " not found", error);
  590. AddAssembly (assembly, true);
  591. return assembly;
  592. }
  593. internal virtual Assembly AddAssemblyByName (string name)
  594. {
  595. if (anames == null)
  596. anames = new Hashtable ();
  597. if (anames.Contains (name)) {
  598. object o = anames [name];
  599. if (o is string)
  600. o = anames [o];
  601. return (Assembly) o;
  602. }
  603. Assembly assembly = null;
  604. Exception error = null;
  605. try {
  606. assembly = Assembly.Load (name);
  607. } catch (Exception e) { error = e; }
  608. if (assembly == null) {
  609. try {
  610. assembly = Assembly.LoadWithPartialName (name);
  611. } catch (Exception e) { error = e; }
  612. }
  613. if (assembly == null)
  614. ThrowParseException ("Assembly " + name + " not found", error);
  615. AddAssembly (assembly, true);
  616. return assembly;
  617. }
  618. internal virtual void ProcessMainAttributes (Hashtable atts)
  619. {
  620. directiveLocation = new System.Web.Compilation.Location (Location);
  621. #if NET_2_0
  622. CompilationSection compConfig;
  623. #else
  624. CompilationConfiguration compConfig;
  625. #endif
  626. compConfig = CompilationConfig;
  627. atts.Remove ("Description"); // ignored
  628. #if NET_1_1
  629. atts.Remove ("CodeBehind"); // ignored
  630. #endif
  631. atts.Remove ("AspCompat"); // ignored
  632. debug = GetBool (atts, "Debug", compConfig.Debug);
  633. compilerOptions = GetString (atts, "CompilerOptions", "");
  634. language = GetString (atts, "Language", "");
  635. if (language.Length != 0)
  636. implicitLanguage = false;
  637. else
  638. language = compConfig.DefaultLanguage;
  639. strictOn = GetBool (atts, "Strict", compConfig.Strict);
  640. explicitOn = GetBool (atts, "Explicit", compConfig.Explicit);
  641. if (atts.ContainsKey ("LinePragmas"))
  642. linePragmasOn = GetBool (atts, "LinePragmas", true);
  643. string inherits = GetString (atts, "Inherits", null);
  644. #if NET_2_0
  645. string srcRealPath = null;
  646. // In ASP 2, the source file is actually integrated with
  647. // the generated file via the use of partial classes. This
  648. // means that the code file has to be confirmed, but not
  649. // used at this point.
  650. src = GetString (atts, "CodeFile", null);
  651. codeFileBaseClass = GetString (atts, "CodeFileBaseClass", null);
  652. if (src == null && codeFileBaseClass != null)
  653. ThrowParseException ("The 'CodeFileBaseClass' attribute cannot be used without a 'CodeFile' attribute");
  654. string legacySrc = GetString (atts, "Src", null);
  655. if (legacySrc != null) {
  656. legacySrc = UrlUtils.Combine (BaseVirtualDir, legacySrc);
  657. GetAssemblyFromSource (legacySrc);
  658. if (src == null) {
  659. src = legacySrc;
  660. legacySrc = MapPath (legacySrc, false);
  661. srcRealPath = legacySrc;
  662. if (!File.Exists (srcRealPath))
  663. ThrowParseException ("File " + src + " not found");
  664. srcIsLegacy = true;
  665. } else
  666. legacySrc = MapPath (legacySrc, false);
  667. AddDependency (legacySrc);
  668. }
  669. if (!srcIsLegacy && src != null && inherits != null) {
  670. // Make sure the source exists
  671. src = UrlUtils.Combine (BaseVirtualDir, src);
  672. srcRealPath = MapPath (src, false);
  673. if (!HostingEnvironment.VirtualPathProvider.FileExists (src))
  674. ThrowParseException ("File " + src + " not found");
  675. // We are going to create a partial class that shares
  676. // the same name as the inherits tag, so reset the
  677. // name. The base type is changed because it is the
  678. // code file's responsibilty to extend the classes
  679. // needed.
  680. partialClassName = inherits;
  681. // Add the code file as an option to the
  682. // compiler. This lets both files be compiled at once.
  683. compilerOptions += " \"" + srcRealPath + "\"";
  684. if (codeFileBaseClass != null) {
  685. try {
  686. codeFileBaseClassType = LoadType (codeFileBaseClass);
  687. } catch (Exception) {
  688. }
  689. if (codeFileBaseClassType == null)
  690. ThrowParseException ("Could not load type '{0}'", codeFileBaseClass);
  691. }
  692. } else if (inherits != null) {
  693. // We just set the inherits directly because this is a
  694. // Single-Page model.
  695. SetBaseType (inherits);
  696. }
  697. #else
  698. string src = GetString (atts, "Src", null);
  699. if (src != null)
  700. srcAssembly = GetAssemblyFromSource (src);
  701. if (inherits != null)
  702. SetBaseType (inherits);
  703. #endif
  704. if (src != null) {
  705. if (VirtualPathUtility.IsAbsolute (src))
  706. src = VirtualPathUtility.ToAppRelative (src);
  707. AddDependency (src);
  708. }
  709. className = GetString (atts, "ClassName", null);
  710. if (className != null) {
  711. #if NET_2_0
  712. string [] identifiers = className.Split ('.');
  713. for (int i = 0; i < identifiers.Length; i++)
  714. if (!CodeGenerator.IsValidLanguageIndependentIdentifier (identifiers [i]))
  715. ThrowParseException (String.Format ("'{0}' is not a valid "
  716. + "value for attribute 'classname'.", className));
  717. #else
  718. if (!CodeGenerator.IsValidLanguageIndependentIdentifier (className))
  719. ThrowParseException (String.Format ("'{0}' is not a valid "
  720. + "value for attribute 'classname'.", className));
  721. #endif
  722. }
  723. #if NET_2_0
  724. if (this is TemplateControlParser)
  725. metaResourceKey = GetString (atts, "meta:resourcekey", null);
  726. if (inherits != null && (this is PageParser || this is UserControlParser) && atts.Count > 0) {
  727. if (unknownMainAttributes == null)
  728. unknownMainAttributes = new List <UnknownAttributeDescriptor> ();
  729. string key, val;
  730. foreach (DictionaryEntry de in atts) {
  731. key = de.Key as string;
  732. val = de.Value as string;
  733. if (String.IsNullOrEmpty (key) || String.IsNullOrEmpty (val))
  734. continue;
  735. CheckUnknownAttribute (key, val, inherits);
  736. }
  737. return;
  738. }
  739. #endif
  740. if (atts.Count > 0)
  741. ThrowParseException ("Unknown attribute: " + GetOneKey (atts));
  742. }
  743. #if NET_2_0
  744. void RegisterTagName (string tagName)
  745. {
  746. if (registeredTagNames == null)
  747. registeredTagNames = new List <string> ();
  748. if (registeredTagNames.Contains (tagName))
  749. return;
  750. registeredTagNames.Add (tagName);
  751. }
  752. void CheckUnknownAttribute (string name, string val, string inherits)
  753. {
  754. MemberInfo mi = null;
  755. bool missing = false;
  756. string memberName = name.Trim ().ToLower (CultureInfo.InvariantCulture);
  757. Type parent = codeFileBaseClassType;
  758. if (parent == null)
  759. parent = baseType;
  760. try {
  761. MemberInfo[] infos = parent.GetMember (memberName,
  762. MemberTypes.Field | MemberTypes.Property,
  763. BindingFlags.Public | BindingFlags.Instance |
  764. BindingFlags.IgnoreCase | BindingFlags.Static);
  765. if (infos.Length != 0) {
  766. // prefer public properties to public methods (it's what MS.NET does)
  767. foreach (MemberInfo tmp in infos) {
  768. if (tmp is PropertyInfo) {
  769. mi = tmp;
  770. break;
  771. }
  772. }
  773. if (mi == null)
  774. mi = infos [0];
  775. } else
  776. missing = true;
  777. } catch (Exception) {
  778. missing = true;
  779. }
  780. if (missing)
  781. ThrowParseException (
  782. "Error parsing attribute '{0}': Type '{1}' does not have a public property named '{0}'",
  783. memberName, inherits);
  784. Type memberType = null;
  785. if (mi is PropertyInfo) {
  786. PropertyInfo pi = mi as PropertyInfo;
  787. if (!pi.CanWrite)
  788. ThrowParseException (
  789. "Error parsing attribute '{0}': The '{0}' property is read-only and cannot be set.",
  790. memberName);
  791. memberType = pi.PropertyType;
  792. } else if (mi is FieldInfo) {
  793. memberType = ((FieldInfo)mi).FieldType;
  794. } else
  795. ThrowParseException ("Could not determine member the kind of '{0}' in base type '{1}",
  796. memberName, inherits);
  797. TypeConverter converter = TypeDescriptor.GetConverter (memberType);
  798. bool convertible = true;
  799. object value = null;
  800. if (converter == null || !converter.CanConvertFrom (typeof (string)))
  801. convertible = false;
  802. if (convertible) {
  803. try {
  804. value = converter.ConvertFromInvariantString (val);
  805. } catch (Exception) {
  806. convertible = false;
  807. }
  808. }
  809. if (!convertible)
  810. ThrowParseException ("Error parsing attribute '{0}': Cannot create an object of type '{1}' from its string representation '{2}' for the '{3}' property.",
  811. memberName, memberType, val, mi.Name);
  812. UnknownAttributeDescriptor desc = new UnknownAttributeDescriptor (mi, value);
  813. unknownMainAttributes.Add (desc);
  814. }
  815. #endif
  816. internal void SetBaseType (string type)
  817. {
  818. Type parent;
  819. if (type == null || type == DefaultBaseTypeName)
  820. parent = DefaultBaseType;
  821. else
  822. parent = null;
  823. if (parent == null) {
  824. #if NET_2_0
  825. parent = LoadType (type);
  826. #else
  827. parent = null;
  828. if (srcAssembly != null)
  829. parent = srcAssembly.GetType (type);
  830. if (parent == null)
  831. parent = LoadType (type);
  832. #endif
  833. if (parent == null)
  834. ThrowParseException ("Cannot find type " + type);
  835. if (!DefaultBaseType.IsAssignableFrom (parent))
  836. ThrowParseException ("The parent type '" + type + "' does not derive from " + DefaultBaseType);
  837. }
  838. #if NET_2_0
  839. var pageParserFilter = PageParserFilter;
  840. if (pageParserFilter != null && !pageParserFilter.AllowBaseType (parent))
  841. throw new HttpException ("Base type '" + parent + "' is not allowed.");
  842. #endif
  843. baseType = parent;
  844. }
  845. internal void SetLanguage (string language)
  846. {
  847. this.language = language;
  848. implicitLanguage = false;
  849. }
  850. internal void PushIncludeDir (string dir)
  851. {
  852. if (includeDirs == null) {
  853. #if NET_2_0
  854. includeDirs = new Stack <string> (1);
  855. #else
  856. includeDirs = new Stack (1);
  857. #endif
  858. }
  859. includeDirs.Push (dir);
  860. }
  861. internal string PopIncludeDir ()
  862. {
  863. if (includeDirs == null || includeDirs.Count == 0)
  864. return null;
  865. return includeDirs.Pop () as string;
  866. }
  867. Assembly GetAssemblyFromSource (string vpath)
  868. {
  869. vpath = UrlUtils.Combine (BaseVirtualDir, vpath);
  870. string realPath = MapPath (vpath, false);
  871. if (!File.Exists (realPath))
  872. ThrowParseException ("File " + vpath + " not found");
  873. AddSourceDependency (vpath);
  874. CompilerResults result;
  875. #if NET_2_0
  876. string tmp;
  877. CompilerParameters parameters;
  878. CodeDomProvider provider = BaseCompiler.CreateProvider (HttpContext.Current, language, out parameters, out tmp);
  879. if (provider == null)
  880. throw new HttpException ("Cannot find provider for language '" + language + "'.");
  881. AssemblyBuilder abuilder = new AssemblyBuilder (provider);
  882. abuilder.CompilerOptions = parameters;
  883. abuilder.AddAssemblyReference (BuildManager.GetReferencedAssemblies () as List <Assembly>);
  884. abuilder.AddCodeFile (realPath);
  885. result = abuilder.BuildAssembly (new VirtualPath (vpath));
  886. #else
  887. result = CachingCompiler.Compile (language, realPath, realPath, assemblies, Debug);
  888. #endif
  889. if (result.NativeCompilerReturnValue != 0) {
  890. using (StreamReader reader = new StreamReader (realPath)) {
  891. throw new CompilationException (realPath, result.Errors, reader.ReadToEnd ());
  892. }
  893. }
  894. AddAssembly (result.CompiledAssembly, true);
  895. return result.CompiledAssembly;
  896. }
  897. internal abstract string DefaultBaseTypeName { get; }
  898. internal abstract string DefaultDirectiveName { get; }
  899. internal bool LinePragmasOn {
  900. get { return linePragmasOn; }
  901. }
  902. #if NET_2_0
  903. internal byte[] MD5Checksum {
  904. get { return md5checksum; }
  905. set { md5checksum = value; }
  906. }
  907. internal PageParserFilter PageParserFilter {
  908. get {
  909. if (pageParserFilter != null)
  910. return pageParserFilter;
  911. Type t = PageParserFilterType;
  912. if (t == null)
  913. return null;
  914. pageParserFilter = Activator.CreateInstance (t) as PageParserFilter;
  915. pageParserFilter.Initialize (this);
  916. return pageParserFilter;
  917. }
  918. }
  919. internal Type PageParserFilterType {
  920. get {
  921. if (pageParserFilterType == null) {
  922. string typeName = PagesConfig.PageParserFilterType;
  923. if (String.IsNullOrEmpty (typeName))
  924. return null;
  925. pageParserFilterType = Type.GetType (typeName, true);
  926. }
  927. return pageParserFilterType;
  928. }
  929. }
  930. #endif
  931. internal Type DefaultBaseType {
  932. get {
  933. Type type = Type.GetType (DefaultBaseTypeName, true);
  934. return type;
  935. }
  936. }
  937. internal ILocation DirectiveLocation {
  938. get { return directiveLocation; }
  939. }
  940. internal string ParserDir {
  941. get {
  942. if (includeDirs == null || includeDirs.Count == 0)
  943. return BaseDir;
  944. return includeDirs.Peek () as string;
  945. }
  946. }
  947. internal string InputFile
  948. {
  949. get { return inputFile; }
  950. set { inputFile = value; }
  951. }
  952. #if NET_2_0
  953. internal bool IsPartial {
  954. get { return (!srcIsLegacy && src != null); }
  955. }
  956. internal string CodeBehindSource {
  957. get {
  958. if (srcIsLegacy)
  959. return null;
  960. return src;
  961. }
  962. }
  963. internal string PartialClassName {
  964. get { return partialClassName; }
  965. }
  966. internal string CodeFileBaseClass {
  967. get { return codeFileBaseClass; }
  968. }
  969. internal string MetaResourceKey {
  970. get { return metaResourceKey; }
  971. }
  972. internal Type CodeFileBaseClassType
  973. {
  974. get { return codeFileBaseClassType; }
  975. }
  976. internal List <UnknownAttributeDescriptor> UnknownMainAttributes
  977. {
  978. get { return unknownMainAttributes; }
  979. }
  980. #endif
  981. internal string Text {
  982. get { return text; }
  983. set { text = value; }
  984. }
  985. internal Type BaseType {
  986. get {
  987. if (baseType == null)
  988. SetBaseType (DefaultBaseTypeName);
  989. return baseType;
  990. }
  991. }
  992. internal bool BaseTypeIsGlobal {
  993. get { return baseTypeIsGlobal; }
  994. set { baseTypeIsGlobal = value; }
  995. }
  996. #if NET_2_0
  997. static long autoClassCounter = 0;
  998. #endif
  999. internal string EncodeIdentifier (string value)
  1000. {
  1001. if (value == null || value.Length == 0 || CodeGenerator.IsValidLanguageIndependentIdentifier (value))
  1002. return value;
  1003. StringBuilder ret = new StringBuilder ();
  1004. char ch = value [0];
  1005. switch (Char.GetUnicodeCategory (ch)) {
  1006. case UnicodeCategory.LetterNumber:
  1007. case UnicodeCategory.LowercaseLetter:
  1008. case UnicodeCategory.TitlecaseLetter:
  1009. case UnicodeCategory.UppercaseLetter:
  1010. case UnicodeCategory.OtherLetter:
  1011. case UnicodeCategory.ModifierLetter:
  1012. case UnicodeCategory.ConnectorPunctuation:
  1013. ret.Append (ch);
  1014. break;
  1015. case UnicodeCategory.DecimalDigitNumber:
  1016. ret.Append ('_');
  1017. ret.Append (ch);
  1018. break;
  1019. default:
  1020. ret.Append ('_');
  1021. break;
  1022. }
  1023. for (int i = 1; i < value.Length; i++) {
  1024. ch = value [i];
  1025. switch (Char.GetUnicodeCategory (ch)) {
  1026. case UnicodeCategory.LetterNumber:
  1027. case UnicodeCategory.LowercaseLetter:
  1028. case UnicodeCategory.TitlecaseLetter:
  1029. case UnicodeCategory.UppercaseLetter:
  1030. case UnicodeCategory.OtherLetter:
  1031. case UnicodeCategory.ModifierLetter:
  1032. case UnicodeCategory.ConnectorPunctuation:
  1033. case UnicodeCategory.DecimalDigitNumber:
  1034. case UnicodeCategory.NonSpacingMark:
  1035. case UnicodeCategory.SpacingCombiningMark:
  1036. case UnicodeCategory.Format:
  1037. ret.Append (ch);
  1038. break;
  1039. default:
  1040. ret.Append ('_');
  1041. break;
  1042. }
  1043. }
  1044. return ret.ToString ();
  1045. }
  1046. internal string ClassName {
  1047. get {
  1048. if (className != null)
  1049. return className;
  1050. #if NET_2_0
  1051. string physPath = HttpContext.Current.Request.PhysicalApplicationPath;
  1052. string inFile;
  1053. if (String.IsNullOrEmpty (inputFile)) {
  1054. inFile = null;
  1055. using (StreamReader sr = Reader as StreamReader) {
  1056. if (sr != null) {
  1057. FileStream fr = sr.BaseStream as FileStream;
  1058. if (fr != null)
  1059. inFile = fr.Name;
  1060. }
  1061. }
  1062. } else
  1063. inFile = inputFile;
  1064. if (String.IsNullOrEmpty (inFile)) {
  1065. // generate a unique class name
  1066. long suffix;
  1067. suffix = Interlocked.Increment (ref autoClassCounter);
  1068. className = String.Format ("autoclass_nosource_{0:x}", suffix);
  1069. return className;
  1070. }
  1071. if (StrUtils.StartsWith (inFile, physPath))
  1072. className = inputFile.Substring (physPath.Length).ToLower (CultureInfo.InvariantCulture);
  1073. else
  1074. #endif
  1075. className = Path.GetFileName (inputFile);
  1076. className = EncodeIdentifier (className);
  1077. return className;
  1078. }
  1079. }
  1080. #if NET_2_0
  1081. internal List <ServerSideScript> Scripts {
  1082. get {
  1083. if (scripts == null)
  1084. scripts = new List <ServerSideScript> ();
  1085. return scripts;
  1086. }
  1087. }
  1088. internal List <string> Imports {
  1089. get { return imports; }
  1090. }
  1091. internal List <string> Interfaces {
  1092. get { return interfaces; }
  1093. }
  1094. #else
  1095. internal ArrayList Scripts {
  1096. get {
  1097. if (scripts == null)
  1098. scripts = new ArrayList ();
  1099. return scripts;
  1100. }
  1101. }
  1102. internal ArrayList Imports {
  1103. get { return imports; }
  1104. }
  1105. internal ArrayList Interfaces {
  1106. get { return interfaces; }
  1107. }
  1108. #endif
  1109. internal ArrayList Assemblies {
  1110. get {
  1111. if (appAssemblyIndex != -1) {
  1112. object o = assemblies [appAssemblyIndex];
  1113. assemblies.RemoveAt (appAssemblyIndex);
  1114. assemblies.Add (o);
  1115. appAssemblyIndex = -1;
  1116. }
  1117. return assemblies;
  1118. }
  1119. }
  1120. internal RootBuilder RootBuilder {
  1121. get {
  1122. #if NET_2_0
  1123. if (rootBuilder != null)
  1124. return rootBuilder;
  1125. AspGenerator generator = AspGenerator;
  1126. if (generator != null)
  1127. rootBuilder = generator.RootBuilder;
  1128. #endif
  1129. return rootBuilder;
  1130. }
  1131. set { rootBuilder = value; }
  1132. }
  1133. internal ArrayList Dependencies {
  1134. get { return dependencies; }
  1135. set { dependencies = value; }
  1136. }
  1137. internal string CompilerOptions {
  1138. get { return compilerOptions; }
  1139. }
  1140. internal string Language {
  1141. get { return language; }
  1142. }
  1143. internal bool ImplicitLanguage {
  1144. get { return implicitLanguage; }
  1145. }
  1146. internal bool StrictOn {
  1147. get { return strictOn; }
  1148. }
  1149. internal bool ExplicitOn {
  1150. get { return explicitOn; }
  1151. }
  1152. internal bool Debug {
  1153. get { return debug; }
  1154. }
  1155. internal bool OutputCache {
  1156. get { return output_cache; }
  1157. }
  1158. internal int OutputCacheDuration {
  1159. get { return oc_duration; }
  1160. }
  1161. #if NET_2_0
  1162. internal OutputCacheParsedParams OutputCacheParsedParameters {
  1163. get { return oc_parsed_params; }
  1164. }
  1165. internal string OutputCacheSqlDependency {
  1166. get { return oc_sqldependency; }
  1167. }
  1168. internal string OutputCacheCacheProfile {
  1169. get { return oc_cacheprofile; }
  1170. }
  1171. internal string OutputCacheVaryByContentEncodings {
  1172. get { return oc_content_encodings; }
  1173. }
  1174. internal bool OutputCacheNoStore {
  1175. get { return oc_nostore; }
  1176. }
  1177. internal virtual TextReader Reader {
  1178. get { return null; }
  1179. set { /* no-op */ }
  1180. }
  1181. #endif
  1182. internal string OutputCacheVaryByHeader {
  1183. get { return oc_header; }
  1184. }
  1185. internal string OutputCacheVaryByCustom {
  1186. get { return oc_custom; }
  1187. }
  1188. internal string OutputCacheVaryByControls {
  1189. get { return oc_controls; }
  1190. }
  1191. internal bool OutputCacheShared {
  1192. get { return oc_shared; }
  1193. }
  1194. internal OutputCacheLocation OutputCacheLocation {
  1195. get { return oc_location; }
  1196. }
  1197. internal string OutputCacheVaryByParam {
  1198. get { return oc_param; }
  1199. }
  1200. #if NET_2_0
  1201. internal List <string> RegisteredTagNames {
  1202. get { return registeredTagNames; }
  1203. }
  1204. internal PagesSection PagesConfig {
  1205. get { return GetConfigSection <PagesSection> ("system.web/pages") as PagesSection; }
  1206. }
  1207. internal AspGenerator AspGenerator {
  1208. get;
  1209. set;
  1210. }
  1211. #else
  1212. internal PagesConfiguration PagesConfig {
  1213. get { return PagesConfiguration.GetInstance (Context); }
  1214. }
  1215. #endif
  1216. }
  1217. }