Beispiel #1
0
        public PowerLogEventStream(
            IConfigurationSource configurationSource,
            IPowerLogEventParser powerLogEventParser,
            IEventDispatcher viewEventDispatcher,
            bool seekEndWhenFileChanges)
        {
            _configurationSource = configurationSource.Require(nameof(configurationSource));
            _powerLogEventParser = powerLogEventParser.Require(nameof(powerLogEventParser));
            _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            _seekEndWhenFileChanges = seekEndWhenFileChanges;

            _filePath = _configurationSource.GetSettings().PowerLogFilePath;

            _eventHandlers.Add(
                new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>(
                    __event =>
            {
                string newFilePath = _configurationSource.GetSettings().PowerLogFilePath;
                if (!newFilePath.Eq(_filePath))
                {
                    Task.Run(
                        () =>
                    {
                        lock (_lock)
                        {
                            _remainingText  = null;
                            _streamPosition = 0L;

                            _filePath = newFilePath;

                            if (_seekEndWhenFileChanges)
                            {
                                SeekEnd_();
                            }
                        }
                    });
                }
            }));

            _eventHandlers.ForEach(__eventHandler => _viewEventDispatcher.RegisterHandler(__eventHandler));
        }
        Models.Client.ConfigurationSettings IConfigurationSource.GetSettings()
        {
            lock (_lock)
            {
                if (!_cachedConfigurationSettings.HasValue)
                {
                    _cachedConfigurationSettings = _configurationSource.GetSettings();
                }

                return(_cachedConfigurationSettings.Value);
            }
        }
Beispiel #3
0
        public FileBasedPowerLogManager(
            AsyncSemaphore asyncMutex,
            IConfigurationSource configurationSource,
            string directoryPath,
            string manifestFileName,
            ICollectionSerializer <Models.Data.SavedLog> savedLogCollectionSerializer,
            IEventDispatcher viewEventDispatcher)
        {
            _asyncMutex                   = asyncMutex.Require(nameof(asyncMutex));
            _configurationSource          = configurationSource.Require(nameof(configurationSource));
            _directoryPath                = directoryPath.Require(nameof(directoryPath));
            _manifestFileName             = manifestFileName.Require(nameof(manifestFileName));
            _savedLogCollectionSerializer = savedLogCollectionSerializer.Require(nameof(savedLogCollectionSerializer));
            _viewEventDispatcher          = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            _powerLogFilePath = _configurationSource.GetSettings().PowerLogFilePath;

            _eventHandlers.Add(
                new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>(
                    __event => _powerLogFilePath = _configurationSource.GetSettings().PowerLogFilePath));

            _eventHandlers.ForEach(__eventHandler => _viewEventDispatcher.RegisterHandler(__eventHandler));
        }
Beispiel #4
0
        public ConfigurationSettingsViewModel(
            IBackgroundWorkInterface backgroundWorkInterface,
            IConfigurationSource configurationSource,
            IConfigurationStorage configurationStorage)
        {
            _backgroundWorkInterface = backgroundWorkInterface.Require(nameof(backgroundWorkInterface));
            _configurationSource     = configurationSource.Require(nameof(configurationSource));
            _configurationStorage    = configurationStorage.Require(nameof(configurationStorage));

            Models.Client.ConfigurationSettings configurationSettings = _configurationSource.GetSettings();

            CardTextOffset    = configurationSettings.CardTextOffset;
            FontSize          = configurationSettings.FontSize;
            _powerLogFilePath = configurationSettings.PowerLogFilePath;
        }
Beispiel #5
0
        public SavedLogViewModel(
            IConfigurationSource configurationSource,
            IPowerLogManager powerLogManager,
            IEventDispatcher viewEventDispatcher,
            Guid id,
            string title,
            DateTimeOffset timestamp,
            string filePath)
        {
            configurationSource.Require(nameof(configurationSource));

            _powerLogManager     = powerLogManager.Require(nameof(powerLogManager));
            _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            ID        = id;
            Title     = title ?? string.Empty;
            Timestamp = timestamp;
            _filePath = filePath;

            _textEditorFilePath = configurationSource.GetSettings().TextEditorFilePath;
        }