|
|
@@ -44,21 +44,20 @@ namespace System.Web.Compilation
|
|
|
{
|
|
|
static object compilationLock = new object ();
|
|
|
const string cachePrefix = "@@Assembly";
|
|
|
+ const string cacheTypePrefix = "@@@Type";
|
|
|
|
|
|
- public static Type GetTypeFromCache (string filename, string typename)
|
|
|
+ public static void InsertType (Type type, string filename)
|
|
|
{
|
|
|
- string key = CachingCompiler.cachePrefix + filename;
|
|
|
- CompilerResults results = (CompilerResults) HttpRuntime.Cache [key];
|
|
|
- if (results == null)
|
|
|
- return null;
|
|
|
-
|
|
|
- Assembly a = results.CompiledAssembly;
|
|
|
- if (a == null)
|
|
|
- return null;
|
|
|
+ string [] cacheKeys = new string [] { cachePrefix + filename };
|
|
|
+ CacheDependency dep = new CacheDependency (null, cacheKeys);
|
|
|
+ HttpRuntime.Cache.Insert (cacheTypePrefix + filename, type, dep);
|
|
|
+ }
|
|
|
|
|
|
- return a.GetType (typename, false);
|
|
|
+ public static Type GetTypeFromCache (string filename)
|
|
|
+ {
|
|
|
+ return (Type) HttpRuntime.Cache [cacheTypePrefix + filename];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static CompilerResults Compile (BaseCompiler compiler)
|
|
|
{
|
|
|
Cache cache = HttpRuntime.Cache;
|
|
|
@@ -153,6 +152,26 @@ namespace System.Web.Compilation
|
|
|
|
|
|
return results;
|
|
|
}
|
|
|
+
|
|
|
+ public static Type CompileAndGetType (string typename, string language, string key,
|
|
|
+ string file, ArrayList assemblies)
|
|
|
+ {
|
|
|
+ CompilerResults result = CachingCompiler.Compile (language, key, file, assemblies);
|
|
|
+ if (result.NativeCompilerReturnValue != 0) {
|
|
|
+ StreamReader reader = new StreamReader (file);
|
|
|
+ throw new CompilationException (file, result.Errors, reader.ReadToEnd ());
|
|
|
+ }
|
|
|
+
|
|
|
+ Assembly assembly = result.CompiledAssembly;
|
|
|
+ if (assembly == null) {
|
|
|
+ StreamReader reader = new StreamReader (file);
|
|
|
+ throw new CompilationException (file, result.Errors, reader.ReadToEnd ());
|
|
|
+ }
|
|
|
+
|
|
|
+ Type type = assembly.GetType (typename, true);
|
|
|
+ InsertType (type, file);
|
|
|
+ return type;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|