2005-01-10 Lluis Sanchez Gual <lluis@novell.com>
authorLluis Sanchez <lluis@novell.com>
Mon, 10 Jan 2005 15:21:19 +0000 (15:21 -0000)
committerLluis Sanchez <lluis@novell.com>
Mon, 10 Jan 2005 15:21:19 +0000 (15:21 -0000)
* TemplateBuilder.cs: Added a special constructor that takes an
attribute provider as parameter. The container type for the template
may be defined in a TemplateContainerAttribute.
* ControlBuilder.cs: Create the TemplateBuilder using that special
constructor.
* TemplateContainerAttribute.cs: Added 2.0 property and ctor.

svn path=/trunk/mcs/; revision=38619

mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/ControlBuilder.cs
mcs/class/System.Web/System.Web.UI/TemplateBuilder.cs
mcs/class/System.Web/System.Web.UI/TemplateContainerAttribute.cs

index cccc9581e089c2a9de253ad37f4049c88e8dd963..ee27c519c77d2c640072bcf744d8fcb97f7c1313 100644 (file)
@@ -1,3 +1,12 @@
+2005-01-10  Lluis Sanchez Gual <lluis@novell.com>
+       
+       * TemplateBuilder.cs: Added a special constructor that takes an
+       attribute provider as parameter. The container type for the template
+       may be defined in a TemplateContainerAttribute.
+       * ControlBuilder.cs: Create the TemplateBuilder using that special
+       constructor.
+       * TemplateContainerAttribute.cs: Added 2.0 property and ctor.
+
 2004-12-20 Lluis Sanchez Gual  <lluis@novell.com>
 
        * IStyleSheet.cs: Added missing "using".
index 0499eff632ce6af5d3e2cdfb57e88670d1b71345..834617cb35f9231fa48efab94677910190fea585 100755 (executable)
@@ -313,7 +313,7 @@ namespace System.Web.UI {
                        if (typeof (ICollection).IsAssignableFrom (propType)) {
                                builder = new CollectionBuilder ();
                        } else if (typeof (ITemplate).IsAssignableFrom (propType)) {
-                               builder = new TemplateBuilder ();
+                               builder = new TemplateBuilder (prop);
                        } else {
                                builder = CreateBuilderFromType (parser, parentBuilder, propType, prop.Name,
                                                                 null, atts, line, fileName);
index 78d591f8f6c14b1e85a78b27a99a47908a034887..ea64fe9e1ed2f71365f5af5cfd5e227f9858a5f8 100644 (file)
 
 using System;
 using System.Collections;
+using System.Reflection;
 
 namespace System.Web.UI
 {
        public class TemplateBuilder : ControlBuilder, ITemplate
        {
                string text;
+               TemplateContainerAttribute containerAttribute;
 
                public TemplateBuilder ()
                {
                }
 
+               internal TemplateBuilder (ICustomAttributeProvider prov)
+               {
+                       object[] ats = prov.GetCustomAttributes (typeof(TemplateContainerAttribute), true);
+                       if (ats.Length > 0) {
+                               containerAttribute = (TemplateContainerAttribute) ats [0];
+                       }
+               }
+
                public virtual string Text {
                        get { return text; }
                        set { text = value; }
                }
+               
+               public Type ContainerType {
+                       get { return containerAttribute != null ? containerAttribute.ContainerType : null; }
+               }
 
                public override void Init (TemplateParser parser,
                                          ControlBuilder parentBuilder,
index aaf2bf58491f7e999fbcab037ccf7e9068f16656..aac8d003efc89b068106056740f92168e14a33c5 100755 (executable)
@@ -28,6 +28,7 @@
 //
 
 using System;
+using System.ComponentModel;
 
 namespace System.Web.UI {
 
@@ -36,6 +37,20 @@ namespace System.Web.UI {
        {
                Type containerType;
                
+#if NET_2_0
+               BindingDirection direction;
+               
+               public TemplateContainerAttribute (Type containerType, BindingDirection direction)
+               {
+                       this.containerType = containerType;
+                       this.direction = direction;
+               }
+               
+               public BindingDirection BindingDirection {
+                       get { return direction; }
+               }
+#endif
+               
                public TemplateContainerAttribute (Type containerType)
                {
                        this.containerType = containerType;