示例#1
0
 internal AppDomainContext(IAssemblyRewriter assemblyRewriter, Logger logger)
     : this(
         new AssemblyLoaderFactory(AppDomain.CurrentDomain.BaseDirectory, assemblyRewriter),
         new Serializer(),
         logger)
 {
 }
示例#2
0
        public AssemblyLoaderFactory(string basePath, IAssemblyRewriter assemblyRewriter)
        {
            ArgumentChecker.NotNull(assemblyRewriter, () => assemblyRewriter);

            _basePath         = basePath;
            _assemblyRewriter = assemblyRewriter;
        }
示例#3
0
        public AssemblyLoaderFactory(string basePath, IAssemblyRewriter assemblyRewriter)
        {
            ArgumentChecker.NotNull(assemblyRewriter, () => assemblyRewriter);

            _basePath = basePath;
            _assemblyRewriter = assemblyRewriter;
        }
示例#4
0
        private T RunFunc <T>(Func <ISmocksContext, T> func, Configuration configuration)
        {
            IAssemblyRewriter rewriter = CreateAssemblyRewriter(func, configuration);

            using (AppDomainContext context = new AppDomainContext(rewriter, configuration.Logger))
            {
                context.Invoke(new Action(() => ServiceLocator.Instance = CreateServiceLocator(configuration)));
                return(context.Invoke(func, _serviceLocator.Resolve <ISmocksContext>()));
            }
        }
示例#5
0
        private void RunAction(Action <ISmocksContext> action, Configuration configuration)
        {
            IAssemblyRewriter rewriter = CreateAssemblyRewriter(action, configuration);

            using (AppDomainContext context = new AppDomainContext(rewriter, configuration.Logger))
            {
                configuration.Logger.Info("Creating service locator for app domain {0}", context);
                context.Invoke(new Action(() => ServiceLocator.Instance = CreateServiceLocator(configuration)));

                configuration.Logger.Info("Invoking action in app domain {0}", context);
                context.Invoke(action, _serviceLocator.Resolve <ISmocksContext>());
            }
        }
示例#6
0
 internal AppDomainContext(IAssemblyRewriter assemblyRewriter)
     : this(assemblyRewriter, null)
 {
 }