예제 #1
0
        /// <summary>
        /// Add a helper service to the manager
        /// </summary>
        /// <param name="service">
        /// Target service
        /// </param>
        /// <param name="autoStart">
        /// Auto-start the service after adding
        /// </param>
        public void Add(IHelperService service, bool autoStart)
        {
            var type = service.GetType();
            IHelperService existService;
            if (this.services.TryGetValue(type, out existService))
            {
                existService.Configuration = service.Configuration;
            }
            else
            {
                this.services.Add(type, service);
                existService = service;
            }

            existService.Logger = this.Logger;

            if (autoStart)
            {
                existService.Initialize();
                existService.Start();
            }
        }