public RFConsoleExecutor( RFEngineDefinition config, IRFProcessingContext context, EngineConfigElement engine, IRFEngineConsole engineConsole) { _config = config; _context = context; _engine = engine; _engineConsole = engineConsole; _isExiting = false; }
public static void InitializeEngine() { var builder = new ContainerBuilder(); builder.RegisterControllers(Assembly.GetExecutingAssembly()); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); var clientControllerAssembly = RFSettings.GetAppSetting("ControllersAssembly", null); if (!string.IsNullOrWhiteSpace(clientControllerAssembly)) { builder.RegisterControllers(AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetModules().First().Name == clientControllerAssembly)); builder.RegisterApiControllers(AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetModules().First().Name == clientControllerAssembly)); } var engine = RIFFSection.GetDefaultEngine(); var config = engine.BuildEngineConfiguration(); EngineConfig = engine; var enableWebProcessing = RFSettings.GetAppSetting("EnableWebProcessing", false); var context = enableWebProcessing ? RFEnvironments.StartConsole(engine.Environment, config, engine.Database, new string[] { "RIFF.Core", "RIFF.Framework", engine.Assembly }).Start() : RFEnvironments.StartWeb(engine.Environment, engine.Database, new string[] { "RIFF.Core", "RIFF.Framework", engine.Assembly }); UserRole = context.UserRole; // this context is for read-only operations builder.RegisterInstance(context).As <IRFProcessingContext>(); builder.RegisterInstance(context).As <IRFSystemContext>(); builder.RegisterInstance(config).As <RFEngineDefinition>(); var engineConsole = config.Console; if (config.Console == null) { throw new Exception("Error initializing engine. Check log for details."); } engineConsole.Initialize(context, config, engine.Database); ConsoleExecutor = new RFConsoleExecutor(config, context, engine, engineConsole); Context = context; var httpConfig = GlobalConfiguration.Configuration; builder.RegisterWebApiFilterProvider(httpConfig); Container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(Container)); httpConfig.DependencyResolver = new AutofacWebApiDependencyResolver(Container); }