Преглед на файлове

2009-01-20 Marek Habersack <[email protected]>

	* Substitution.cs: added. Fixes bug #467460

2009-01-20  Marek Habersack  <[email protected]>

	* System.Web.dll.sources: added System.Web.UI.WebControls/Substitution.cs

svn path=/trunk/mcs/; revision=123865
Marek Habersack преди 17 години
родител
ревизия
2279cf0cf8

+ 4 - 0
mcs/class/System.Web/ChangeLog

@@ -1,3 +1,7 @@
+2009-01-20  Marek Habersack  <[email protected]>
+
+	* System.Web.dll.sources: added System.Web.UI.WebControls/Substitution.cs
+
 2008-12-23  Marek Habersack  <[email protected]>
 
 	* Makefile (TEST_RESOURCE_FILES): added Test/mainsoft/NunitWebResources/CustomSectionEmptyCollection.aspx

+ 4 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,7 @@
+2009-01-20  Marek Habersack  <[email protected]>
+
+	* Substitution.cs: added. Fixes bug #467460
+
 2009-01-13  Marek Habersack  <[email protected]>
 
 	* XmlBuilder.cs: updates related to ControlBuilder cleanup.

+ 106 - 0
mcs/class/System.Web/System.Web.UI.WebControls/Substitution.cs

@@ -0,0 +1,106 @@
+//
+// System.Web.UI.WebControls.Substitution.cs
+//
+// Authors:
+//	Marek Habersack ([email protected])
+//
+// (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+using System;
+using System.ComponentModel;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace System.Web.UI.WebControls
+{
+	[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+	[DefaultProperty ("MethodName")]
+	[ParseChildren (true)]
+	[PersistChildren (false)]
+	public class Substitution : Control
+	{
+		[DefaultValue ("")]
+		[WebCategory ("Behavior")]
+		public virtual string MethodName {
+			get {
+				string methodName = ViewState ["MethodName"] as string;
+				if (String.IsNullOrEmpty (methodName))
+					return String.Empty;
+
+				return methodName;
+			}
+			
+			set { ViewState ["MethodName"] = value; }
+		}
+
+		public Substitution ()
+		{}
+
+		protected override ControlCollection CreateControlCollection ()
+		{
+			return new EmptyControlCollection (this);
+		}
+
+		[MonoTODO ("Why override?")]
+		protected internal override void OnPreRender (EventArgs e)
+		{
+			base.OnPreRender (e);
+		}
+
+		protected internal override void Render (HtmlTextWriter writer)
+		{
+			string method = MethodName;
+			if (method.Length == 0)
+				return;
+			
+			TemplateControl tc = TemplateControl;
+			if (tc == null)
+				return;
+			
+			HttpContext ctx = Context;
+			HttpResponse resp = ctx != null ? ctx.Response : null;
+
+			if (resp == null)
+				return;
+
+			resp.WriteSubstitution (CreateCallback (method, tc));
+		}
+
+		HttpResponseSubstitutionCallback CreateCallback (string method, TemplateControl tc)
+		{
+			try {
+				return Delegate.CreateDelegate (typeof(HttpResponseSubstitutionCallback),
+								tc.GetType (),
+								method,
+								true,
+								true) as HttpResponseSubstitutionCallback;
+			} catch (Exception ex) {
+				throw new HttpException ("Cannot find static method '" + method + "' matching HttpResponseSubstitutionCallback", ex);
+			}
+		}
+	}
+}
+#endif

+ 1 - 0
mcs/class/System.Web/System.Web.dll.sources

@@ -1044,6 +1044,7 @@ System.Web.UI.WebControls/StringArrayConverter.cs
 System.Web.UI.WebControls/Style.cs
 System.Web.UI.WebControls/SubMenuStyleCollection.cs
 System.Web.UI.WebControls/SubMenuStyle.cs
+System.Web.UI.WebControls/Substitution.cs
 System.Web.UI.WebControls/TableCaptionAlign.cs
 System.Web.UI.WebControls/TableCellCollection.cs
 System.Web.UI.WebControls/TableCellControlBuilder.cs