コード例 #1
0
 public RootRunner(IRunListener listener, IAppDomainFactory appDomainFactory, IResourceManager resourceManager, IResultFactory resultFactory)
 {
     _listener = listener;
       _appDomainFactory = appDomainFactory;
       _resourceManager = resourceManager;
       _resultFactory = resultFactory;
 }
コード例 #2
0
 public RootRunner(IRunListener listener, IAppDomainFactory appDomainFactory, IResourceManager resourceManager, IResultFactory resultFactory)
 {
     _listener         = listener;
     _appDomainFactory = appDomainFactory;
     _resourceManager  = resourceManager;
     _resultFactory    = resultFactory;
 }
コード例 #3
0
        public static IRazorEngineService Create(IConfigCreator configCreator, IAppDomainFactory appDomainFactory)
        {
            configCreator = configCreator ?? new DefaultConfigCreator();
            var config   = configCreator.CreateConfiguration();
            var isolated = new IsolatedRazorEngineService(configCreator, appDomainFactory);

            return(new DynamicWrapperService(isolated, true, config.AllowMissingPropertiesOnDynamic));
        }
コード例 #4
0
 public Module(ILoggerContainer primaryLoggerContainer,
     IDirectoryController directories,
     IAppDomainFactory appDomainFactory,
     ModuleProxyTypeDictionary proxyTypes)
 {
     this.proxyTypes = proxyTypes;
     this.appDomainFactory = appDomainFactory;
     this.primaryLoggerContainer = primaryLoggerContainer;
     this.directories = directories;
 }
コード例 #5
0
        /// <summary>
        /// Initialises a new instance of <see cref="IsolatedTemplateService"/>
        /// </summary>
        /// <param name="language">The code language.</param>
        /// <param name="encoding">The encoding.</param>
        /// <param name="appDomainFactory">The application domain factory.</param>
        public IsolatedTemplateService(Language language, Encoding encoding, IAppDomainFactory appDomainFactory)
        {
            _appDomain = CreateAppDomain(appDomainFactory ?? new DefaultAppDomainFactory());

            string assemblyName = TemplateServiceType.Assembly.FullName;
            string typeName     = TemplateServiceType.FullName;

            _proxy = (ITemplateService)_appDomain.CreateInstance(
                assemblyName, typeName, false, BindingFlags.NonPublic | BindingFlags.Instance,
                null, new object[] { language, encoding }, CultureInfo.CurrentCulture, null).Unwrap();
        }
コード例 #6
0
        public static IRazorEngineService Create(IConfigCreator configCreator, IAppDomainFactory appDomainFactory)
        {
            configCreator = configCreator ?? new DefaultConfigCreator();
            var config = configCreator.CreateConfiguration();

            if (config.DisableTempFileLocking)
            {
                throw new InvalidOperationException("DisableTempFileLocking is not supported in the context of Isolation, because it will escape any kind of sandbox. Besides that it's not required because RazorEngine will be able to cleanup the tempfiles in this scenario. Just make sure to call AppDomain.Unload when you are done.");
            }

            var isolated = new IsolatedRazorEngineService(configCreator, appDomainFactory);

            return(new DynamicWrapperService(isolated, true, config.AllowMissingPropertiesOnDynamic));
        }
コード例 #7
0
        /// <summary>
        /// Creates an application domain.
        /// </summary>
        /// <param name="factory">The application domain factory.</param>
        /// <returns>An instance of <see cref="AppDomain"/>.</returns>
        private static AppDomain CreateAppDomain(IAppDomainFactory factory)
        {
            var domain = factory.CreateAppDomain();

            if (domain == null)
            {
                throw new InvalidOperationException("The application domain factory did not create an application domain.");
            }

            if (domain == AppDomain.CurrentDomain)
            {
                throw new InvalidOperationException("The application domain factory returned the current application domain which cannot be used for isolation.");
            }

            return(domain);
        }
コード例 #8
0
        internal IsolatedRazorEngineService(IConfigCreator configCreator, IAppDomainFactory appDomainFactory)
        {
            _appDomain = CreateAppDomain(appDomainFactory ?? new DefaultAppDomainFactory());
            var config = configCreator ?? new DefaultConfigCreator();

            ObjectHandle handle =
                Activator.CreateInstanceFrom(
                    _appDomain, typeof(SanboxHelper).Assembly.ManifestModule.FullyQualifiedName,
                    typeof(SanboxHelper).FullName
                );

            using (var helper = (SanboxHelper)handle.Unwrap())
            {
                _proxy = helper.CreateEngine(config);
            }
        }
コード例 #9
0
        internal IsolatedRazorEngineService(IConfigCreator configCreator, IAppDomainFactory appDomainFactory)
        {
            _appDomain = CreateAppDomain(appDomainFactory ?? new DefaultAppDomainFactory());
            var config = configCreator ?? new DefaultConfigCreator();

            ObjectHandle handle =
                Activator.CreateInstanceFrom(
                    _appDomain, typeof(SanboxHelper).Assembly.ManifestModule.FullyQualifiedName,
                    typeof(SanboxHelper).FullName
                    );

            using (var helper = (SanboxHelper)handle.Unwrap())
            {
                _proxy = helper.CreateEngine(config);
            }
        }
コード例 #10
0
        public virtual void before_each()
        {
            autoSubstitute = new AutoSubstitute();

            targetDomain     = autoSubstitute.Resolve <ITargetAppDomain>();
            appDomainFactory = autoSubstitute.Resolve <IAppDomainFactory>();
            appDomainFactory.Create(somePath).Returns(targetDomain);

            proxyable        = autoSubstitute.Resolve <IDummyProxyable>();
            proxyableFactory = autoSubstitute.Resolve <IProxyableFactory <IDummyProxyable> >();
            proxyableFactory.CreateProxy(targetDomain).Returns(proxyable);

            runner = new CrossDomainRunner <IDummyProxyable, float>(appDomainFactory, proxyableFactory);

            proxyable.PassInput(Arg.Any <float>()).Returns(callInfo =>
            {
                float input = callInfo.Arg <float>();
                return(input);
            });
        }
コード例 #11
0
 /// <summary>
 /// Initialises a new instance of <see cref="IsolatedTemplateService"/>
 /// </summary>
 /// <param name="appDomainFactory">The application domain factory.</param>
 public IsolatedTemplateService(IAppDomainFactory appDomainFactory)
     : this(Language.CSharp, Encoding.Html, appDomainFactory)
 {
 }
コード例 #12
0
        /// <summary>
        /// Creates an application domain.
        /// </summary>
        /// <param name="factory">The application domain factory.</param>
        /// <returns>An instance of <see cref="AppDomain"/>.</returns>
        private static AppDomain CreateAppDomain(IAppDomainFactory factory)
        {
            var domain = factory.CreateAppDomain();
            if (domain == null)
                throw new InvalidOperationException("The application domain factory did not create an application domain.");

            if (domain == AppDomain.CurrentDomain)
                throw new InvalidOperationException("The application domain factory returned the current application domain which cannot be used for isolation.");

            return domain;
        }
コード例 #13
0
        public static IRazorEngineService Create(IConfigCreator configCreator, IAppDomainFactory appDomainFactory)
        {
            configCreator = configCreator ?? new DefaultConfigCreator();
            var config = configCreator.CreateConfiguration();
            if (config.DisableTempFileLocking)
            {
                throw new InvalidOperationException("DisableTempFileLocking is not supported in the context of Isolation, because it will escape any kind of sandbox. Besides that it's not required because RazorEngine will be able to cleanup the tempfiles in this scenario. Just make sure to call AppDomain.Unload when you are done.");
            }

            var isolated = new IsolatedRazorEngineService(configCreator, appDomainFactory);
            return new DynamicWrapperService(isolated, true, config.AllowMissingPropertiesOnDynamic);
        }
コード例 #14
0
 public static IRazorEngineService Create(IAppDomainFactory appDomainFactory)
 {
     return Create(null, appDomainFactory);
 }
コード例 #15
0
        // initial implementation taken from
        // http://thevalerios.net/matt/2008/06/run-anonymous-methods-in-another-appdomain/

        public CrossDomainRunner(IAppDomainFactory appDomainFactory, IProxyableFactory <TProxyable> proxyableFactory)
        {
            this.appDomainFactory = appDomainFactory;
            this.proxyableFactory = proxyableFactory;
        }
コード例 #16
0
 public static IRazorEngineService Create(IConfigCreator configCreator, IAppDomainFactory appDomainFactory)
 {
     configCreator = configCreator ?? new DefaultConfigCreator();
     var config = configCreator.CreateConfiguration();
     var isolated = new IsolatedRazorEngineService(configCreator, appDomainFactory);
     return new DynamicWrapperService(isolated, true, config.AllowMissingPropertiesOnDynamic);
 }
コード例 #17
0
ファイル: ComponentManager.cs プロジェクト: forki/HostBox
 /// <summary>
 /// Initializes a new instance of the class <see cref="ComponentManager"/>.
 /// </summary>
 /// <param name="componentFactory"> Component factory. </param>
 /// <param name="appDomainSetupFactory"> Application domain configuration factory, in which component loads. </param>
 /// <param name="appDomainFactory"> Component application domain factory. </param>
 public ComponentManager(IComponentFactory componentFactory, IAppDomainSetupFactory appDomainSetupFactory, IAppDomainFactory appDomainFactory)
 {
     this.componentFactory      = componentFactory;
     this.appDomainSetupFactory = appDomainSetupFactory;
     this.appDomainFactory      = appDomainFactory;
 }
コード例 #18
0
 public static IRazorEngineService Create(IAppDomainFactory appDomainFactory)
 {
     return(Create(null, appDomainFactory));
 }