Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            Title = TypeHelper.ApplicationNameWithVersion;

            InitializeDataSource();

            Directory.CreateDirectory(BaseApplication.AppDataPath);

            var compositionsPath = Path.Combine(BaseApplication.AppDataPath, "Compositions");
            var strategiesPath   = Path.Combine(BaseApplication.AppDataPath, "Strategies");
            var logsPath         = Path.Combine(BaseApplication.AppDataPath, "Logs");

            _settingsFile = Path.Combine(BaseApplication.AppDataPath, "settings.xml");

            var logManager = new LogManager();

            logManager.Listeners.Add(new FileLogListener
            {
                Append          = true,
                LogDirectory    = logsPath,
                MaxLength       = 1024 * 1024 * 100 /* 100mb */,
                MaxCount        = 10,
                SeparateByDates = SeparateByDateModes.SubDirectories,
            });
            logManager.Listeners.Add(new GuiLogListener(Monitor));

            _strategiesRegistry = new StrategiesRegistry(compositionsPath, strategiesPath);
            logManager.Sources.Add(_strategiesRegistry);
            _strategiesRegistry.Init();

            _layoutManager          = new LayoutManager(DockingManager);
            _layoutManager.Changed += SaveSettings;
            logManager.Sources.Add(_layoutManager);

            var entityRegistry  = ConfigManager.GetService <IEntityRegistry>();
            var storageRegistry = ConfigManager.GetService <IStorageRegistry>();

            _connector = new Connector(entityRegistry, storageRegistry)
            {
                StorageAdapter =
                {
                    DaysLoad = TimeSpan.Zero
                }
            };
            _connector.Connected       += ConnectorOnConnectionStateChanged;
            _connector.Disconnected    += ConnectorOnConnectionStateChanged;
            _connector.ConnectionError += ConnectorOnConnectionError;
            logManager.Sources.Add(_connector);

            ConfigManager.RegisterService(logManager);
            ConfigManager.RegisterService(_strategiesRegistry);
            ConfigManager.RegisterService(_layoutManager);
            ConfigManager.RegisterService <IConnector>(_connector);
            ConfigManager.RegisterService <ISecurityProvider>(_connector);

            SolutionExplorer.Compositions = _strategiesRegistry.Compositions;
            SolutionExplorer.Strategies   = _strategiesRegistry.Strategies;
        }
Ejemplo n.º 2
0
        private void InitializeStrategiesRegistry()
        {
            var compositionsPath = Path.Combine(BaseApplication.AppDataPath, "Compositions");
            var strategiesPath   = Path.Combine(BaseApplication.AppDataPath, "Strategies");

            _strategiesRegistry = new StrategiesRegistry(compositionsPath, strategiesPath);
            ConfigManager.GetService <LogManager>().Sources.Add(_strategiesRegistry);
            _strategiesRegistry.Init();
            ConfigManager.RegisterService(_strategiesRegistry);
        }
Ejemplo n.º 3
0
		public MainWindow()
		{
			InitializeComponent();

			Title = TypeHelper.ApplicationNameWithVersion;

			InitializeDataSource();

			Directory.CreateDirectory(BaseApplication.AppDataPath);

			var compositionsPath = Path.Combine(BaseApplication.AppDataPath, "Compositions");
			var strategiesPath = Path.Combine(BaseApplication.AppDataPath, "Strategies");
			var logsPath = Path.Combine(BaseApplication.AppDataPath, "Logs");

			_settingsFile = Path.Combine(BaseApplication.AppDataPath, "settings.xml");

			var logManager = new LogManager();
			logManager.Listeners.Add(new FileLogListener
			{
				Append = true,
				LogDirectory = logsPath,
				MaxLength = 1024 * 1024 * 100 /* 100mb */,
				MaxCount = 10,
				SeparateByDates = SeparateByDateModes.SubDirectories,
			});
			logManager.Listeners.Add(new GuiLogListener(Monitor));

			_strategiesRegistry = new StrategiesRegistry(compositionsPath, strategiesPath);
			logManager.Sources.Add(_strategiesRegistry);
			_strategiesRegistry.Init();

			_layoutManager = new LayoutManager(DockingManager);
			_layoutManager.Changed += SaveSettings;
			logManager.Sources.Add(_layoutManager);

			var entityRegistry = ConfigManager.GetService<IEntityRegistry>();
			var storageRegistry = ConfigManager.GetService<IStorageRegistry>();

			_connector = new Connector(entityRegistry, storageRegistry)
			{
				StorageAdapter =
				{
					DaysLoad = TimeSpan.Zero
				}
			};
			_connector.Connected += ConnectorOnConnectionStateChanged;
			_connector.Disconnected += ConnectorOnConnectionStateChanged;
			_connector.ConnectionError += ConnectorOnConnectionError;
			logManager.Sources.Add(_connector);

			ConfigManager.RegisterService(logManager);
			ConfigManager.RegisterService(_strategiesRegistry);
			ConfigManager.RegisterService(_layoutManager);
			ConfigManager.RegisterService<IConnector>(_connector);
			ConfigManager.RegisterService<ISecurityProvider>(_connector);

			SolutionExplorer.Compositions = _strategiesRegistry.Compositions;
			SolutionExplorer.Strategies = _strategiesRegistry.Strategies;
		}