/// <summary> /// Creates the <see cref="AppDomain"/> that will host the compiled code. /// </summary> private void CreateDomain() { string templateDomainFriendlyName = "TextTemplate TemplateDomain #" + (++_TemplateIndex); var setup = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), }; _TemplateDomain = AppDomain.CreateDomain(templateDomainFriendlyName, null, setup); _TemplateProxy = (ITemplateProxy)_TemplateDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "TextTemplate.TemplateProxy"); }
/// <summary> /// Invalidates internal data structures, releasing compiled versions of /// the template and associated information. /// </summary> public void Invalidate() { AssertNotDisposed(); _templateProxy = null; if (_templateDomain != null) { AppDomain.Unload(_templateDomain); } _templateDomain = null; }
/// <summary> /// Creates the <see cref="AppDomain" /> that will host the compiled code. /// </summary> private void CreateDomain() { var templateDomainFriendlyName = string.Format("{0} TemplateDomain #{1}", TypeHelper.GetNamespace(), ++_templateIndex); var setup = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) }; _templateDomain = AppDomain.CreateDomain(templateDomainFriendlyName, null, setup); _templateProxy = (ITemplateProxy)_templateDomain.CreateInstanceAndUnwrap( Assembly.GetExecutingAssembly().FullName, string.Format("{0}.TemplateProxy", TypeHelper.GetNamespace())); }