WebServiceCompiler.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // System.Web.Compilation.WebServiceCompiler
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System;
  10. using System.IO;
  11. using System.Web.UI;
  12. namespace System.Web.Compilation
  13. {
  14. class WebServiceCompiler
  15. {
  16. private WebServiceCompiler ()
  17. {
  18. }
  19. public static Type CompileIntoType (SimpleWebHandlerParser wService)
  20. {
  21. string sourceFile = GenerateSourceFile (wService);
  22. Type type = TemplateFactory.GetTypeFromSource (wService.PhysicalPath, sourceFile);
  23. if (type.FullName != wService.ClassName)
  24. throw new ApplicationException (String.Format (
  25. "Class={0}, but the class compiled is {1}",
  26. wService.ClassName,
  27. type.FullName));
  28. return type;
  29. }
  30. private static string GenerateSourceFile (SimpleWebHandlerParser wService)
  31. {
  32. //FIXME: should get Tmp dir for this application
  33. string csName = Path.GetTempFileName ();
  34. StreamWriter output = new StreamWriter (File.OpenWrite (csName));
  35. output.Write (wService.Program);
  36. output.Close ();
  37. return csName;
  38. }
  39. }
  40. }