ControlBuilder.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. //
  2. // System.Web.UI.ControlBuilder.cs
  3. //
  4. // Authors:
  5. // Duncan Mak ([email protected])
  6. // Gonzalo Paniagua Javier ([email protected])
  7. //
  8. // (C) 2002, 2003 Ximian, Inc. (http://www.ximian.com)
  9. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System.Collections;
  31. using System.Configuration;
  32. using System.CodeDom;
  33. using System.Globalization;
  34. using System.Reflection;
  35. using System.Security.Permissions;
  36. using System.Web.Compilation;
  37. using System.Web.Configuration;
  38. using System.IO;
  39. using System.Web.UI.WebControls;
  40. namespace System.Web.UI {
  41. // CAS
  42. [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  43. [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
  44. public class ControlBuilder
  45. {
  46. internal static readonly BindingFlags FlagsNoCase = BindingFlags.Public |
  47. BindingFlags.Instance |
  48. BindingFlags.Static |
  49. BindingFlags.IgnoreCase;
  50. ControlBuilder myNamingContainer;
  51. TemplateParser parser;
  52. Type parserType;
  53. ControlBuilder parentBuilder;
  54. Type type;
  55. string tagName;
  56. string originalTagName;
  57. string id;
  58. IDictionary attribs;
  59. int line;
  60. string fileName;
  61. bool childrenAsProperties;
  62. bool isIParserAccessor = true;
  63. bool hasAspCode;
  64. ControlBuilder defaultPropertyBuilder;
  65. ArrayList children;
  66. ArrayList templateChildren;
  67. static int nextID;
  68. bool haveParserVariable;
  69. CodeMemberMethod method;
  70. CodeStatementCollection methodStatements;
  71. CodeMemberMethod renderMethod;
  72. int renderIndex;
  73. bool isProperty;
  74. ILocation location;
  75. ArrayList otherTags;
  76. public ControlBuilder ()
  77. {
  78. }
  79. internal ControlBuilder (TemplateParser parser,
  80. ControlBuilder parentBuilder,
  81. Type type,
  82. string tagName,
  83. string id,
  84. IDictionary attribs,
  85. int line,
  86. string sourceFileName)
  87. {
  88. this.parser = parser;
  89. this.parserType = parser != null ? parser.GetType () : null;
  90. this.parentBuilder = parentBuilder;
  91. this.type = type;
  92. this.tagName = tagName;
  93. this.id = id;
  94. this.attribs = attribs;
  95. this.line = line;
  96. this.fileName = sourceFileName;
  97. }
  98. internal void EnsureOtherTags ()
  99. {
  100. if (otherTags == null)
  101. otherTags = new ArrayList ();
  102. }
  103. internal ControlBuilder ParentBuilder {
  104. get { return parentBuilder; }
  105. }
  106. internal IDictionary Attributes {
  107. get { return attribs; }
  108. }
  109. internal int Line {
  110. get { return line; }
  111. set { line = value; }
  112. }
  113. internal string FileName {
  114. get { return fileName; }
  115. set { fileName = value; }
  116. }
  117. internal ControlBuilder DefaultPropertyBuilder {
  118. get { return defaultPropertyBuilder; }
  119. }
  120. internal bool HaveParserVariable {
  121. get { return haveParserVariable; }
  122. set { haveParserVariable = value; }
  123. }
  124. internal CodeMemberMethod Method {
  125. get { return method; }
  126. set { method = value; }
  127. }
  128. #if NET_2_0
  129. internal CodeMemberMethod DataBindingMethod {
  130. get;
  131. set;
  132. }
  133. #endif
  134. internal CodeStatementCollection MethodStatements {
  135. get { return methodStatements; }
  136. set { methodStatements = value; }
  137. }
  138. internal CodeMemberMethod RenderMethod {
  139. get { return renderMethod; }
  140. set { renderMethod = value; }
  141. }
  142. internal int RenderIndex {
  143. get { return renderIndex; }
  144. }
  145. internal bool IsProperty {
  146. get { return isProperty; }
  147. }
  148. internal ILocation Location {
  149. get { return location; }
  150. set { location = value; }
  151. }
  152. internal ArrayList OtherTags {
  153. get { return otherTags; }
  154. }
  155. public Type ControlType {
  156. get { return type; }
  157. }
  158. protected bool FChildrenAsProperties {
  159. get { return childrenAsProperties; }
  160. }
  161. protected bool FIsNonParserAccessor {
  162. get { return !isIParserAccessor; }
  163. }
  164. public bool HasAspCode {
  165. get { return hasAspCode; }
  166. }
  167. public string ID {
  168. get { return id; }
  169. set { id = value; }
  170. }
  171. internal ArrayList Children {
  172. get { return children; }
  173. }
  174. internal ArrayList TemplateChildren {
  175. get { return templateChildren; }
  176. }
  177. internal void SetControlType (Type t)
  178. {
  179. type = t;
  180. }
  181. protected bool InDesigner {
  182. get { return false; }
  183. }
  184. public Type NamingContainerType {
  185. get {
  186. ControlBuilder cb = myNamingContainer;
  187. if (cb == null)
  188. return typeof (Control);
  189. return cb.ControlType;
  190. }
  191. }
  192. ControlBuilder MyNamingContainer {
  193. get {
  194. if (myNamingContainer == null) {
  195. Type controlType = parentBuilder != null ? parentBuilder.ControlType : null;
  196. if (parentBuilder == null && controlType == null)
  197. myNamingContainer = null;
  198. else if (parentBuilder is TemplateBuilder)
  199. myNamingContainer = parentBuilder;
  200. else if (controlType != null && typeof (INamingContainer).IsAssignableFrom (controlType))
  201. myNamingContainer = parentBuilder;
  202. else
  203. myNamingContainer = parentBuilder.MyNamingContainer;
  204. }
  205. return myNamingContainer;
  206. }
  207. }
  208. #if NET_2_0
  209. public virtual
  210. #else
  211. internal
  212. #endif
  213. Type BindingContainerType {
  214. get {
  215. ControlBuilder cb = (this is TemplateBuilder && !(this is RootBuilder)) ? this : MyNamingContainer;
  216. if (cb == null) {
  217. if (this is RootBuilder && parserType == typeof (PageParser))
  218. return typeof (Page);
  219. return typeof (Control);
  220. }
  221. #if NET_2_0
  222. if (cb != this && cb is ContentBuilderInternal && !typeof (INonBindingContainer).IsAssignableFrom (cb.BindingContainerType))
  223. return cb.BindingContainerType;
  224. #endif
  225. Type ct;
  226. if (cb is TemplateBuilder) {
  227. ct = ((TemplateBuilder) cb).ContainerType;
  228. if (typeof (INonBindingContainer).IsAssignableFrom (ct))
  229. return MyNamingContainer.BindingContainerType;
  230. if (ct != null)
  231. return ct;
  232. ct = cb.ControlType;
  233. if (ct == null)
  234. return typeof (Control);
  235. if (typeof (INonBindingContainer).IsAssignableFrom (ct) || !typeof (INamingContainer).IsAssignableFrom (ct))
  236. return MyNamingContainer.BindingContainerType;
  237. return ct;
  238. }
  239. ct = cb.ControlType;
  240. if (ct == null)
  241. return typeof (Control);
  242. if (typeof (INonBindingContainer).IsAssignableFrom (ct) || !typeof (INamingContainer).IsAssignableFrom (ct))
  243. return MyNamingContainer.BindingContainerType;
  244. return cb.ControlType;
  245. }
  246. }
  247. internal TemplateBuilder ParentTemplateBuilder {
  248. get {
  249. if (parentBuilder == null)
  250. return null;
  251. else if (parentBuilder is TemplateBuilder)
  252. return (TemplateBuilder) parentBuilder;
  253. else
  254. return parentBuilder.ParentTemplateBuilder;
  255. }
  256. }
  257. protected TemplateParser Parser {
  258. get { return parser; }
  259. }
  260. public string TagName {
  261. get { return tagName; }
  262. }
  263. internal string OriginalTagName {
  264. get {
  265. if (originalTagName == null || originalTagName.Length == 0)
  266. return TagName;
  267. return originalTagName;
  268. }
  269. }
  270. internal RootBuilder Root {
  271. get {
  272. if (typeof (RootBuilder).IsAssignableFrom (GetType ()))
  273. return (RootBuilder) this;
  274. return (RootBuilder) parentBuilder.Root;
  275. }
  276. }
  277. internal bool ChildrenAsProperties {
  278. get { return childrenAsProperties; }
  279. }
  280. internal string GetAttribute (string name)
  281. {
  282. if (attribs == null)
  283. return null;
  284. return attribs [name] as string;
  285. }
  286. internal void IncreaseRenderIndex ()
  287. {
  288. renderIndex++;
  289. }
  290. void AddChild (object child)
  291. {
  292. if (children == null)
  293. children = new ArrayList ();
  294. children.Add (child);
  295. ControlBuilder cb = child as ControlBuilder;
  296. if (cb != null && cb is TemplateBuilder) {
  297. if (templateChildren == null)
  298. templateChildren = new ArrayList ();
  299. templateChildren.Add (child);
  300. }
  301. #if NET_2_0
  302. if (parser == null)
  303. return;
  304. string tag = cb != null ? cb.TagName : null;
  305. if (String.IsNullOrEmpty (tag))
  306. return;
  307. RootBuilder rb = Root;
  308. AspComponentFoundry foundry = rb != null ? rb.Foundry : null;
  309. if (foundry == null)
  310. return;
  311. AspComponent component = foundry.GetComponent (tag);
  312. if (component == null || !component.FromConfig)
  313. return;
  314. parser.AddImport (component.Namespace);
  315. parser.AddDependency (component.Source);
  316. #endif
  317. }
  318. public virtual bool AllowWhitespaceLiterals ()
  319. {
  320. return true;
  321. }
  322. public virtual void AppendLiteralString (string s)
  323. {
  324. if (s == null || s.Length == 0)
  325. return;
  326. if (childrenAsProperties || !isIParserAccessor) {
  327. if (defaultPropertyBuilder != null) {
  328. defaultPropertyBuilder.AppendLiteralString (s);
  329. } else if (s.Trim ().Length != 0) {
  330. throw new HttpException (String.Format ("Literal content not allowed for '{0}' {1} \"{2}\"",
  331. tagName, GetType (), s));
  332. }
  333. return;
  334. }
  335. if (!AllowWhitespaceLiterals () && s.Trim ().Length == 0)
  336. return;
  337. if (HtmlDecodeLiterals ())
  338. s = HttpUtility.HtmlDecode (s);
  339. AddChild (s);
  340. }
  341. public virtual void AppendSubBuilder (ControlBuilder subBuilder)
  342. {
  343. subBuilder.OnAppendToParentBuilder (this);
  344. subBuilder.parentBuilder = this;
  345. if (childrenAsProperties) {
  346. AppendToProperty (subBuilder);
  347. return;
  348. }
  349. if (typeof (CodeRenderBuilder).IsAssignableFrom (subBuilder.GetType ())) {
  350. AppendCode (subBuilder);
  351. return;
  352. }
  353. AddChild (subBuilder);
  354. }
  355. void AppendToProperty (ControlBuilder subBuilder)
  356. {
  357. if (typeof (CodeRenderBuilder) == subBuilder.GetType ())
  358. throw new HttpException ("Code render not supported here.");
  359. if (defaultPropertyBuilder != null) {
  360. defaultPropertyBuilder.AppendSubBuilder (subBuilder);
  361. return;
  362. }
  363. AddChild (subBuilder);
  364. }
  365. void AppendCode (ControlBuilder subBuilder)
  366. {
  367. if (type != null && !(typeof (Control).IsAssignableFrom (type)))
  368. throw new HttpException ("Code render not supported here.");
  369. if (typeof (CodeRenderBuilder) == subBuilder.GetType ())
  370. hasAspCode = true;
  371. AddChild (subBuilder);
  372. }
  373. public virtual void CloseControl ()
  374. {
  375. }
  376. #if NET_2_0
  377. static Type MapTagType (Type tagType)
  378. {
  379. if (tagType == null)
  380. return null;
  381. PagesSection ps = WebConfigurationManager.GetWebApplicationSection ("system.web/pages") as PagesSection;
  382. if (ps == null)
  383. return tagType;
  384. TagMapCollection tags = ps.TagMapping;
  385. if (tags == null || tags.Count == 0)
  386. return tagType;
  387. string tagTypeName = tagType.ToString ();
  388. Type mappedType, originalType;
  389. string originalTypeName = String.Empty, mappedTypeName = String.Empty;
  390. bool missingType;
  391. Exception error;
  392. foreach (TagMapInfo tmi in tags) {
  393. error = null;
  394. originalType = null;
  395. try {
  396. originalTypeName = tmi.TagType;
  397. originalType = HttpApplication.LoadType (originalTypeName);
  398. if (originalType == null)
  399. missingType = true;
  400. else
  401. missingType = false;
  402. } catch (Exception ex) {
  403. missingType = true;
  404. error = ex;
  405. }
  406. if (missingType)
  407. throw new HttpException (String.Format ("Could not load type {0}", originalTypeName), error);
  408. if (originalTypeName == tagTypeName) {
  409. mappedTypeName = tmi.MappedTagType;
  410. error = null;
  411. mappedType = null;
  412. try {
  413. mappedType = HttpApplication.LoadType (mappedTypeName);
  414. if (mappedType == null)
  415. missingType = true;
  416. else
  417. missingType = false;
  418. } catch (Exception ex) {
  419. missingType = true;
  420. error = ex;
  421. }
  422. if (missingType)
  423. throw new HttpException (String.Format ("Could not load type {0}", mappedTypeName),
  424. error);
  425. if (!mappedType.IsSubclassOf (originalType))
  426. throw new ConfigurationErrorsException (
  427. String.Format ("The specified type '{0}' used for mapping must inherit from the original type '{1}'.", mappedTypeName, originalTypeName));
  428. return mappedType;
  429. }
  430. }
  431. return tagType;
  432. }
  433. #endif
  434. public static ControlBuilder CreateBuilderFromType (TemplateParser parser,
  435. ControlBuilder parentBuilder,
  436. Type type,
  437. string tagName,
  438. string id,
  439. IDictionary attribs,
  440. int line,
  441. string sourceFileName)
  442. {
  443. Type tagType;
  444. #if NET_2_0
  445. tagType = MapTagType (type);
  446. #else
  447. tagType = type;
  448. #endif
  449. ControlBuilder builder;
  450. object [] atts = tagType.GetCustomAttributes (typeof (ControlBuilderAttribute), true);
  451. if (atts != null && atts.Length > 0) {
  452. ControlBuilderAttribute att = (ControlBuilderAttribute) atts [0];
  453. builder = (ControlBuilder) Activator.CreateInstance (att.BuilderType);
  454. } else {
  455. builder = new ControlBuilder ();
  456. }
  457. builder.Init (parser, parentBuilder, tagType, tagName, id, attribs);
  458. builder.line = line;
  459. builder.fileName = sourceFileName;
  460. return builder;
  461. }
  462. public virtual Type GetChildControlType (string tagName, IDictionary attribs)
  463. {
  464. return null;
  465. }
  466. public virtual bool HasBody ()
  467. {
  468. return true;
  469. }
  470. public virtual bool HtmlDecodeLiterals ()
  471. {
  472. return false;
  473. }
  474. ControlBuilder CreatePropertyBuilder (string propName, TemplateParser parser, IDictionary atts)
  475. {
  476. int idx;
  477. string propertyName;
  478. if ((idx = propName.IndexOf (':')) >= 0)
  479. propertyName = propName.Substring (idx + 1);
  480. else
  481. propertyName = propName;
  482. PropertyInfo prop = type.GetProperty (propertyName, FlagsNoCase);
  483. if (prop == null) {
  484. string msg = String.Format ("Property {0} not found in type {1}", propertyName, type);
  485. throw new HttpException (msg);
  486. }
  487. Type propType = prop.PropertyType;
  488. ControlBuilder builder = null;
  489. if (typeof (ICollection).IsAssignableFrom (propType)) {
  490. builder = new CollectionBuilder ();
  491. } else if (typeof (ITemplate).IsAssignableFrom (propType)) {
  492. builder = new TemplateBuilder (prop);
  493. } else if (typeof (string) == propType) {
  494. builder = new StringPropertyBuilder (prop.Name);
  495. } else {
  496. builder = CreateBuilderFromType (parser, parentBuilder, propType, prop.Name,
  497. null, atts, line, fileName);
  498. builder.isProperty = true;
  499. if (idx >= 0)
  500. builder.originalTagName = propName;
  501. return builder;
  502. }
  503. builder.Init (parser, this, null, prop.Name, null, atts);
  504. builder.fileName = fileName;
  505. builder.line = line;
  506. builder.isProperty = true;
  507. if (idx >= 0)
  508. builder.originalTagName = propName;
  509. return builder;
  510. }
  511. public virtual void Init (TemplateParser parser,
  512. ControlBuilder parentBuilder,
  513. Type type,
  514. string tagName,
  515. string id,
  516. IDictionary attribs)
  517. {
  518. this.parser = parser;
  519. if (parser != null)
  520. this.location = parser.Location;
  521. this.parentBuilder = parentBuilder;
  522. this.type = type;
  523. this.tagName = tagName;
  524. this.id = id;
  525. this.attribs = attribs;
  526. if (type == null)
  527. return;
  528. if (this is TemplateBuilder)
  529. return;
  530. object [] atts = type.GetCustomAttributes (typeof (ParseChildrenAttribute), true);
  531. if (!typeof (IParserAccessor).IsAssignableFrom (type) && atts.Length == 0) {
  532. isIParserAccessor = false;
  533. childrenAsProperties = true;
  534. } else if (atts.Length > 0) {
  535. ParseChildrenAttribute att = (ParseChildrenAttribute) atts [0];
  536. childrenAsProperties = att.ChildrenAsProperties;
  537. if (childrenAsProperties && att.DefaultProperty.Length != 0)
  538. defaultPropertyBuilder = CreatePropertyBuilder (att.DefaultProperty,
  539. parser, null);
  540. }
  541. }
  542. public virtual bool NeedsTagInnerText ()
  543. {
  544. return false;
  545. }
  546. public virtual void OnAppendToParentBuilder (ControlBuilder parentBuilder)
  547. {
  548. if (defaultPropertyBuilder == null)
  549. return;
  550. ControlBuilder old = defaultPropertyBuilder;
  551. defaultPropertyBuilder = null;
  552. AppendSubBuilder (old);
  553. }
  554. internal void SetTagName (string name)
  555. {
  556. tagName = name;
  557. }
  558. public virtual void SetTagInnerText (string text)
  559. {
  560. }
  561. internal string GetNextID (string proposedID)
  562. {
  563. if (proposedID != null && proposedID.Trim ().Length != 0)
  564. return proposedID;
  565. return "_bctrl_" + nextID++;
  566. }
  567. internal virtual ControlBuilder CreateSubBuilder (string tagid,
  568. Hashtable atts,
  569. Type childType,
  570. TemplateParser parser,
  571. ILocation location)
  572. {
  573. ControlBuilder childBuilder = null;
  574. if (childrenAsProperties) {
  575. if (defaultPropertyBuilder == null)
  576. childBuilder = CreatePropertyBuilder (tagid, parser, atts);
  577. else {
  578. if (String.Compare (defaultPropertyBuilder.TagName, tagid, true, CultureInfo.InvariantCulture) == 0) {
  579. // The child tag is the same what our default property name. Act as if there was
  580. // no default property builder, or otherwise we'll end up with invalid nested
  581. // builder call.
  582. defaultPropertyBuilder = null;
  583. childBuilder = CreatePropertyBuilder (tagid, parser, atts);
  584. } else
  585. childBuilder = defaultPropertyBuilder.CreateSubBuilder (tagid, atts,
  586. null, parser,
  587. location);
  588. }
  589. return childBuilder;
  590. }
  591. if (String.Compare (tagName, tagid, true, CultureInfo.InvariantCulture) == 0)
  592. return null;
  593. childType = GetChildControlType (tagid, atts);
  594. if (childType == null)
  595. return null;
  596. childBuilder = CreateBuilderFromType (parser, this, childType, tagid, id, atts,
  597. location.BeginLine, location.Filename);
  598. return childBuilder;
  599. }
  600. internal virtual object CreateInstance ()
  601. {
  602. // HtmlGenericControl, HtmlTableCell...
  603. object [] atts = type.GetCustomAttributes (typeof (ConstructorNeedsTagAttribute), true);
  604. object [] args = null;
  605. if (atts != null && atts.Length > 0) {
  606. ConstructorNeedsTagAttribute att = (ConstructorNeedsTagAttribute) atts [0];
  607. if (att.NeedsTag)
  608. args = new object [] {tagName};
  609. }
  610. return Activator.CreateInstance (type, args);
  611. }
  612. internal virtual void CreateChildren (object parent)
  613. {
  614. if (children == null || children.Count == 0)
  615. return;
  616. IParserAccessor parser = parent as IParserAccessor;
  617. if (parser == null)
  618. return;
  619. foreach (object o in children) {
  620. if (o is string) {
  621. parser.AddParsedSubObject (new LiteralControl ((string) o));
  622. } else {
  623. parser.AddParsedSubObject (((ControlBuilder) o).CreateInstance ());
  624. }
  625. }
  626. }
  627. #if NET_2_0
  628. [MonoTODO ("unsure, lack documentation")]
  629. public virtual object BuildObject ()
  630. {
  631. return CreateInstance ();
  632. }
  633. public virtual void ProcessGeneratedCode(CodeCompileUnit codeCompileUnit,
  634. CodeTypeDeclaration baseType,
  635. CodeTypeDeclaration derivedType,
  636. CodeMemberMethod buildMethod,
  637. CodeMemberMethod dataBindingMethod)
  638. {
  639. // nothing to do
  640. }
  641. internal void ResetState()
  642. {
  643. renderIndex = 0;
  644. haveParserVariable = false;
  645. if (Children != null) {
  646. foreach (object child in Children) {
  647. ControlBuilder cb = child as ControlBuilder;
  648. if (cb != null)
  649. cb.ResetState ();
  650. }
  651. }
  652. }
  653. #endif
  654. }
  655. }