public void Dispose() { AppDomain separateAppDomain = this._separateAppDomain; if (separateAppDomain != null) { AppDomain.Unload(separateAppDomain); this._separateAppDomain = null; } this._regexCompilationProxy = null; }
public RegexCompilationProxyWrapper(bool alwaysCompileRegexInSeparateAppDomain) { if (alwaysCompileRegexInSeparateAppDomain) { AppDomain separateAppDomain = this._separateAppDomain = AppDomain.CreateDomain("RegexCompiler Isolation AppDomain", null, AppDomain.CurrentDomain.SetupInformation); Assembly assembly = Assembly.GetExecutingAssembly(); if (!assembly.GlobalAssemblyCache) { separateAppDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs e) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); return((e.Name == executingAssembly.FullName) ? executingAssembly : null); }; } this._regexCompilationProxy = (RegexCompilationProxy)separateAppDomain.CreateInstanceAndUnwrap(assembly.FullName, typeof(RegexCompilationProxy).FullName); } else { this._regexCompilationProxy = new RegexCompilationProxy(); } }
public RegexCompilationProxyWrapper(bool alwaysCompileRegexInSeparateAppDomain) { if (alwaysCompileRegexInSeparateAppDomain) { AppDomain separateAppDomain = this._separateAppDomain = AppDomain.CreateDomain("RegexCompiler Isolation AppDomain", null, AppDomain.CurrentDomain.SetupInformation); Assembly assembly = Assembly.GetExecutingAssembly(); if (!assembly.GlobalAssemblyCache) { separateAppDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs e) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); return (e.Name == executingAssembly.FullName) ? executingAssembly : null; }; } this._regexCompilationProxy = (RegexCompilationProxy)separateAppDomain.CreateInstanceAndUnwrap(assembly.FullName, typeof(RegexCompilationProxy).FullName); } else { this._regexCompilationProxy = new RegexCompilationProxy(); } }