Exemplo n.º 1
0
        /// <summary>
        /// Starts the specified configuration.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="container">The container.</param>
        public static void Start(ITaskManagerConfig config, IContainer container)
        {
            Stop();

            _taskRunners.AddRange(config.Runners);


            /////Play safe with the duplicate tasks
            //var orig = container.Options.AllowOverridingRegistrations;

            //container.Options.AllowOverridingRegistrations = true;

            for (int runnerIndex = 0; runnerIndex < _taskRunners.Count; runnerIndex++)
            {
                container.Register(_taskRunners[runnerIndex].TaskType);
            }

            if (Bootstrap != null)
            {
                Bootstrap(container);
            }


            /////Restore it back for the developer
            //container.Options.AllowOverridingRegistrations = orig;

            //try
            //{
            //    container.Verify();
            //}
            //catch(Exception e)
            //{
            //    Log.Error(string.Format("Error while verifying the container - {0}", e));
            //    throw;
            //}

            ExecutionContext.InternalContainer = container;

            for (int runnerIndex = 0; runnerIndex < _taskRunners.Count; runnerIndex++)
            {
                _taskRunners[runnerIndex].Start();
            }
            Log.Information("Task Manager started");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the specified configuration.
        /// </summary>
        /// <param name="config">The configuration.</param>
        public static void Start(ITaskManagerConfig config)
        {
            IContainer container = new DefaultContainer();

            Start(config, container);
        }