Files
mono/mcs/class/System.Web/System.Web.Compilation/WebServiceCompiler.cs
T
Gonzalo Paniagua Javier be2bff830e 2002-11-26 Gonzalo Paniagua Javier <[email protected]>
* list: added/removed files.

	* System.Web.Compilation/AspGenerator.cs: reworked user control
	compilation. Provide the options as a Hashtable for use in compilation.
	Create the user controls in the private bin path of the domain.

	* System.Web.Compilation/BaseCompiler.cs: base class for the various
	compiler types.

	* System.Web.Compilation/CachingCompiler.cs: actually executes mcs and
	do some poor caching (it will use Cache when finished).

	* System.Web.Compilation/CompilationException.cs: this exception has
	enough information to generate a nice error page.
	* System.Web.Compilation/CompilationResult.cs: used in caching.

	* System.Web.Compilation/PageCompiler.cs: now derives from BaseCompiler

	* System.Web.Compilation/TemplateFactory.cs: no longer needed.

	* System.Web.Compilation/UserControlCompiler.cs: new class used when
	compiling user controls.
	* System.Web.Compilation/WebServiceCompiler.cs: derives from
	BaseCompiler.
	* System.Web.Mail/SmtpMail.cs: i don't wanna see that warning :-).
	* System.Web.UI/TemplateParser.cs: fixed BaseType.
	* System.Web.UI/UserControlParser.cs: helper class to compile user
	controls.

svn path=/trunk/mcs/; revision=9191
2002-11-26 02:52:25 +00:00

86 lines
2.0 KiB
C#

//
// System.Web.Compilation.WebServiceCompiler
//
// Authors:
// Gonzalo Paniagua Javier ([email protected])
//
// (C) 2002 Ximian, Inc (http://www.ximian.com)
//
using System;
using System.IO;
using System.Reflection;
using System.Web.UI;
namespace System.Web.Compilation
{
class WebServiceCompiler : BaseCompiler
{
SimpleWebHandlerParser wService;
string sourceFile;
private WebServiceCompiler (SimpleWebHandlerParser wService)
{
this.wService = wService;
}
public static Type CompileIntoType (SimpleWebHandlerParser wService)
{
CompilationCacheItem item = CachingCompiler.GetCached (wService.PhysicalPath);
if (item != null && item.Result != null) {
if (item.Result != null)
return item.Result.Data as Type;
throw new CompilationException (item.Result);
}
WebServiceCompiler wsc = new WebServiceCompiler (wService);
return wsc.GetCompiledType ();
}
static string GenerateSourceFile (SimpleWebHandlerParser wService)
{
//FIXME: should get Tmp dir for this application
string csName = Path.GetTempFileName ();
StreamWriter output = new StreamWriter (File.OpenWrite (csName));
output.Write (wService.Program);
output.Close ();
return csName;
}
public override Type GetCompiledType ()
{
sourceFile = GenerateSourceFile (wService);
CachingCompiler compiler = new CachingCompiler (this);
CompilationResult result = new CompilationResult ();
if (compiler.Compile (result) == false)
throw new CompilationException (result);
Assembly assembly = Assembly.LoadFrom (result.OutputFile);
Type [] types = assembly.GetTypes ();
Type type = types [0];
if (type.FullName != wService.ClassName)
throw new ApplicationException (String.Format (
"Class={0}, but the class compiled is {1}",
wService.ClassName,
type.FullName));
result.Data = type;
return type;
}
public override string Key {
get {
return wService.PhysicalPath;
}
}
public override string SourceFile {
get {
return sourceFile;
}
}
}
}