Inheritance: System.Configuration.ConfigurationSection
コード例 #1
0
ファイル: HubService.cs プロジェクト: breslavsky/queue
        protected override void OnStart(string[] args)
        {
            logger.Info("Starting service...");

            try
            {
                container = new UnityContainer();
                container.RegisterInstance(container);
                ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

                configuration = new ConfigurationManager(HostMetadata.HubApp, Environment.SpecialFolder.CommonApplicationData);
                container.RegisterInstance(configuration);

                settings = configuration.GetSection<HubSettings>(HubSettings.SectionKey);
                container.RegisterInstance(settings);

                var culture = settings.Language.GetCulture();
                Thread.CurrentThread.CurrentCulture = culture;
                CultureInfo.DefaultThreadCurrentCulture = culture;

                hub = new HubInstance(settings);
                hub.Start();

                logger.Info("Service started");
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
        }
コード例 #2
0
ファイル: HubInstance.cs プロジェクト: breslavsky/queue
        public HubInstance(HubSettings settings)
        {
            this.settings = settings;
            ServiceLocator.Current.GetInstance<UnityContainer>()
                .BuildUp(this);

            LoadDrivers();
            CreateServices();
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: breslavsky/queue
        public MainForm()
        {
            InitializeComponent();

            var container = new UnityContainer();
            container.RegisterInstance(container);
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));

            configuration = new ConfigurationManager(HostMetadata.HubApp, Environment.SpecialFolder.CommonApplicationData);
            container.RegisterInstance(configuration);

            settings = configuration.GetSection<HubSettings>(HubSettings.SectionKey);
            container.RegisterInstance(settings);

            string exePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), HostMetadata.HubServiceExe);
            serviceManager = new ServiceManager(HostMetadata.HubServiceName, exePath);
        }