internal AppDomainContext(IAssemblyRewriter assemblyRewriter, Logger logger) : this( new AssemblyLoaderFactory(AppDomain.CurrentDomain.BaseDirectory, assemblyRewriter), new Serializer(), logger) { }
public AssemblyLoaderFactory(string basePath, IAssemblyRewriter assemblyRewriter) { ArgumentChecker.NotNull(assemblyRewriter, () => assemblyRewriter); _basePath = basePath; _assemblyRewriter = assemblyRewriter; }
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>())); } }
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>()); } }
internal AppDomainContext(IAssemblyRewriter assemblyRewriter) : this(assemblyRewriter, null) { }