Răsfoiți Sursa

2003-08-01 Gonzalo Paniagua Javier <[email protected]>

	* System.Web.dll.sources: added WebHandlerParser.cs

	* System.Web.Compilation/Directive.cs: support @WebHandler.

	* System.Web.UI/SimpleHandlerFactory.cs: implemented GetHandler.
	* System.Web.UI/WebHandlerParser.cs: new file that parses .ashx files.

svn path=/trunk/mcs/; revision=16971
Gonzalo Paniagua Javier 22 ani în urmă
părinte
comite
21c46d96a3

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

@@ -1,3 +1,7 @@
+2003-08-01  Gonzalo Paniagua Javier <[email protected]>
+
+	* Directive.cs: support @WebHandler.
+	
 2003-07-16  Gonzalo Paniagua Javier <[email protected]>
 
 	* TemplateControlCompiler.cs: support string []. Fixes bug #46415.

+ 5 - 0
mcs/class/System.Web/System.Web.Compilation/Directive.cs

@@ -93,6 +93,11 @@ namespace System.Web.Compilation
 			foreach (string att in webservice_atts) valid_attributes.Add (att, null);
 			directivesHash.Add ("WEBSERVICE", valid_attributes);
 
+			valid_attributes = new Hashtable (provider, comparer);
+			// same attributes as webservice
+			foreach (string att in webservice_atts) valid_attributes.Add (att, null);
+			directivesHash.Add ("WEBHANDLER", valid_attributes);
+
 			valid_attributes = new Hashtable (provider, comparer);
 			foreach (string att in application_atts) valid_attributes.Add (att, null);
 			directivesHash.Add ("APPLICATION", valid_attributes);

+ 5 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,8 @@
+2003-08-01  Gonzalo Paniagua Javier <[email protected]>
+
+	* SimpleHandlerFactory.cs: implemented GetHandler.
+	* WebHandlerParser.cs: new file that parses .ashx files.
+
 2003-07-30  Andreas Nahr <[email protected]>
 
 	* PersistenceModeAttribute.cs: Fixed wrong AttributeUsage

+ 7 - 5
mcs/class/System.Web/System.Web.UI/SimpleHandlerFactory.cs

@@ -4,7 +4,7 @@
 // Authors:
 //	Gonzalo Paniagua Javier ([email protected])
 //
-// (C) 2002 Ximian, Inc (http://www.ximian.com)
+// (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
 //
 
 using System.Web;
@@ -13,17 +13,19 @@ namespace System.Web.UI
 {
 	class SimpleHandlerFactory : IHttpHandlerFactory
 	{
-		[MonoTODO]
 		public virtual IHttpHandler GetHandler (HttpContext context,
 							string requestType,
 							string virtualPath,
 							string path)
 		{
-			// This should handle *.ashx files
-			throw new NotImplementedException ();
+			Type type = WebHandlerParser.GetCompiledType (context, virtualPath, path);
+			if (!(typeof (IHttpHandler).IsAssignableFrom (type)))
+				throw new HttpException ("Type does not implement IHttpHandler: " + type.FullName);
+
+			return Activator.CreateInstance (type) as IHttpHandler;
 		}
 
-		public virtual void ReleaseHandler (System.Web.IHttpHandler handler)
+		public virtual void ReleaseHandler (IHttpHandler handler)
 		{
 		}
 	}

+ 36 - 0
mcs/class/System.Web/System.Web.UI/WebHandlerParser.cs

@@ -0,0 +1,36 @@
+//
+// System.Web.UI.WebHandlerParser
+//
+// Authors:
+//	Gonzalo Paniagua Javier ([email protected])
+//
+// (C) 2003 Ximian, Inc (http://www.ximian.com)
+//
+
+using System.Web;
+using System.Web.Compilation;
+
+namespace System.Web.UI
+{
+	class WebHandlerParser : SimpleWebHandlerParser
+	{
+		private WebHandlerParser (HttpContext context, string virtualPath, string physicalPath)
+			: base (context, virtualPath, physicalPath)
+		{
+		}
+
+		public static Type GetCompiledType (HttpContext context, string virtualPath, string physicalPath)
+		{
+			WebHandlerParser parser = new WebHandlerParser (context, virtualPath, physicalPath);
+			// WebServiceCompiler also does this job.
+			return WebServiceCompiler.CompileIntoType (parser);
+		}
+
+		protected override string DefaultDirectiveName {
+			get {
+				return "webhandler";
+			}
+		}
+	}
+}
+

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

@@ -237,6 +237,7 @@ System.Web.UI/UserControlControlBuilder.cs
 System.Web.UI/Utils.cs
 System.Web.UI/ValidationPropertyAttribute.cs
 System.Web.UI/ValidatorCollection.cs
+System.Web.UI/WebHandlerParser.cs
 System.Web.UI/WebServiceParser.cs
 System.Web.UI/ObjectTagBuilder.cs
 System.Web.UI/LosFormatter.cs