예제 #1
0
        /// <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");
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
        /// <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()));
        }