Ver Fonte

2008-04-26 Marek Habersack <[email protected]>

        * GenericBuildProvider.cs: the Parse () method should reuse the
        previously opened TextReader when calling generator.Parse (), to
        avoid opening the input file multiple times. Fixes bug #383881

2008-04-26  Marek Habersack  <[email protected]>

        * VirtualPath.cs: added a new property, PhysicalPath.


svn path=/trunk/mcs/; revision=101897
Marek Habersack há 17 anos atrás
pai
commit
cf7acfe771

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

@@ -1,3 +1,9 @@
+2008-04-26  Marek Habersack  <[email protected]>
+
+	* GenericBuildProvider.cs: the Parse () method should reuse the
+	previously opened TextReader when calling generator.Parse (), to
+	avoid opening the input file multiple times. Fixes bug #383881
+
 2008-04-25  Marek Habersack  <[email protected]>
 
 	* AspGenerator.cs: put some safeguards in, to make sure streams

+ 16 - 3
mcs/class/System.Web/System.Web.Compilation/GenericBuildProvider.cs

@@ -45,6 +45,7 @@ namespace System.Web.Compilation
 		TParser _parser;
 		CompilerType _compilerType;
 		BaseCompiler _compiler;
+		TextReader _reader;
 		bool _parsed;
 		bool _codeGenerated;
 		
@@ -67,7 +68,19 @@ namespace System.Web.Compilation
 
 			if (!IsDirectoryBuilder) {
 				AspGenerator generator = CreateAspGenerator (parser);
-				generator.Parse ();
+				if (_reader != null) {
+					HttpContext ctx = HttpContext.Current;
+					HttpRequest req = ctx != null ? ctx.Request : null;
+					string filename;
+					
+					if (req != null)
+						filename = req.MapPath (VirtualPath);
+					else
+						filename = null;
+					
+					generator.Parse (_reader, filename, true);
+				} else
+					generator.Parse ();
 			}
 			
 			_parsed = true;
@@ -172,8 +185,8 @@ namespace System.Web.Compilation
 					
 					if (!IsDirectoryBuilder) {
 						string physicalPath;
-						TextReader reader = SpecialOpenReader (vp, out physicalPath);
-						_parser = CreateParser (vp, physicalPath, reader, HttpContext.Current);
+						_reader = SpecialOpenReader (vp, out physicalPath);
+						_parser = CreateParser (vp, physicalPath, _reader, HttpContext.Current);
 					} else
 						_parser = CreateParser (vp, null,  HttpContext.Current);
 					

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

@@ -1,3 +1,7 @@
+2008-04-26  Marek Habersack  <[email protected]>
+
+	* VirtualPath.cs: added a new property, PhysicalPath.
+
 2008-04-25  Gert Driesen  <[email protected]>
 
 	* HttpResponse.cs: Use double quotes in link to match MS.

+ 18 - 1
mcs/class/System.Web/System.Web/VirtualPath.cs

@@ -40,6 +40,7 @@ namespace System.Web
 		string _extension;
 		string _directory;
 		string _currentRequestDirectory;
+		string _physicalPath;
 		
 		public bool IsAbsolute {
 			get;
@@ -145,7 +146,23 @@ namespace System.Web
 
 			set { _currentRequestDirectory = value; }
 		}
-		
+
+		public string PhysicalPath {
+			get {
+				if (_physicalPath != null)
+					return _physicalPath;
+
+				HttpContext ctx = HttpContext.Current;
+				HttpRequest req = ctx != null ? ctx.Request : null;
+				if (req != null)
+					_physicalPath = req.MapPath (Absolute);
+				else
+					return null;
+				
+				return _physicalPath;
+			}
+		}
+				
 		public VirtualPath (string vpath)
 		{
 			Original = vpath;