All pastes #287894 Raw Edit

Something

public text v1 · immutable
#287894 ·published 2006-12-21 21:36 UTC
rendered paste body
Index: System.Web.Configuration_2.0/TagMapInfo.cs
===================================================================
--- System.Web.Configuration_2.0/TagMapInfo.cs	(revision 69863)
+++ System.Web.Configuration_2.0/TagMapInfo.cs	(working copy)
@@ -60,6 +60,10 @@
 			properties.Add (tagTypeProp);
 		}
 
+		internal TagMapInfo ()
+		{
+		}
+		
 		public TagMapInfo (string tagTypeName, string mappedTagTypeName)
 		{
 			this.TagType = tagTypeName;
Index: System.Web.Configuration_2.0/TagMapCollection.cs
===================================================================
--- System.Web.Configuration_2.0/TagMapCollection.cs	(revision 69863)
+++ System.Web.Configuration_2.0/TagMapCollection.cs	(working copy)
@@ -62,7 +62,7 @@
 
 		protected override ConfigurationElement CreateNewElement ()
 		{
-			return new TagMapInfo ("", "");
+			return new TagMapInfo ();
 		}
 
 		protected override object GetElementKey (ConfigurationElement element)
Index: System.Web.UI/ControlBuilder.cs
===================================================================
--- System.Web.UI/ControlBuilder.cs	(revision 69863)
+++ System.Web.UI/ControlBuilder.cs	(working copy)
@@ -33,6 +33,7 @@
 using System.Reflection;
 using System.Security.Permissions;
 using System.Web.Compilation;
+using System.Web.Configuration;
 
 namespace System.Web.UI {
 
@@ -298,6 +299,33 @@
 		{
 		}
 
+#if NET_2_0
+		static Type MapTagType (Type tagType)
+		{
+			if (tagType == null)
+				return null;
+			
+			PagesSection ps = WebConfigurationManager.GetSection ("system.web/pages") as PagesSection;
+			if (ps == null)
+				return tagType;
+
+			TagMapCollection tags = ps.TagMapping;
+			if (tags == null || tags.Count == 0)
+				return tagType;
+			string tagTypeName = tagType.ToString ();
+			foreach (TagMapInfo tmi in tags)
+				if (tmi.TagType == tagTypeName) {
+					try {
+						return Type.GetType (tmi.MappedTagType, true);
+					} catch (Exception ex) {
+						throw new HttpException (String.Format ("Unable to map tag type {0}", tagTypeName),
+									 ex);
+					}
+				}
+			return tagType;
+		}
+#endif
+
 		public static ControlBuilder CreateBuilderFromType (TemplateParser parser,
 								    ControlBuilder parentBuilder,
 								    Type type,
@@ -307,8 +335,15 @@
 								    int line,
 								    string sourceFileName)
 		{
+
+			Type tagType;
+#if NET_2_0
+			tagType = MapTagType (type);
+#else
+			tagType = type;
+#endif
 			ControlBuilder  builder;
-			object [] atts = type.GetCustomAttributes (typeof (ControlBuilderAttribute), true);
+			object [] atts = tagType.GetCustomAttributes (typeof (ControlBuilderAttribute), true);
 			if (atts != null && atts.Length > 0) {
 				ControlBuilderAttribute att = (ControlBuilderAttribute) atts [0];
 				builder = (ControlBuilder) Activator.CreateInstance (att.BuilderType);
@@ -316,7 +351,7 @@
 				builder = new ControlBuilder ();
 			}
 
-			builder.Init (parser, parentBuilder, type, tagName, id, attribs);
+			builder.Init (parser, parentBuilder, tagType, tagName, id, attribs);
 			builder.line = line;
 			builder.fileName = sourceFileName;
 			return builder;