public NavigationPresenter(INavigationView view,
            ISettingsSerializer settingsSerializer,
            IKeyboardListener keyboardListener,
            IMatchModelMapper matchModelMapper,
            IPresentationService presentationService,
            INavigationServiceBuilder navigationServiceBuilder)
        {
            _view = view;
            _settingsSerializer = settingsSerializer;
            _keyboardListener = keyboardListener;
            _matchModelMapper = matchModelMapper;
            _navigationServiceBuilder = navigationServiceBuilder;
            _presentationService = presentationService;

            Settings settings = _settingsSerializer.Deserialize();

            _keyboardListener.KeyCombinationPressed += GlobalKeyCombinationPressed;
            _keyboardListener.StartListening(settings.GlobalKeyCombination);

            _view.CurrentSettings = settings;
            _view.ShowMatches(new List<MatchModel> {new MatchModel(_matchModelMapper, Resources.InitialMatchesMessage)});
            _view.ShowInitializingScreen = true;

            //Initialize navigation service asynchronously, as it may require a long operation (file system parsing).
            //Clone settings to avoid any coupling
            Settings settingsCopy = settings.Clone() as Settings;
            InitializeDelegate initialize = Initialize;
            initialize.BeginInvoke(settingsCopy, EndInitialize, initialize);
        }
        public NavigationPresenter(INavigationView view,
                                   ISettingsSerializer settingsSerializer,
                                   IKeyboardListener keyboardListener,
                                   IMatchModelMapper matchModelMapper,
                                   IPresentationService presentationService,
                                   INavigationServiceBuilder navigationServiceBuilder)
        {
            _view = view;
            _settingsSerializer       = settingsSerializer;
            _keyboardListener         = keyboardListener;
            _matchModelMapper         = matchModelMapper;
            _navigationServiceBuilder = navigationServiceBuilder;
            _presentationService      = presentationService;

            Settings settings = _settingsSerializer.Deserialize();

            _keyboardListener.KeyCombinationPressed += GlobalKeyCombinationPressed;
            _keyboardListener.StartListening(settings.GlobalKeyCombination);

            _view.CurrentSettings = settings;
            _view.ShowMatches(new List <MatchModel> {
                new MatchModel(_matchModelMapper, Resources.InitialMatchesMessage)
            });
            _view.ShowInitializingScreen = true;

            //Initialize navigation service asynchronously, as it may require a long operation (file system parsing).
            //Clone settings to avoid any coupling
            Settings           settingsCopy = settings.Clone() as Settings;
            InitializeDelegate initialize   = Initialize;

            initialize.BeginInvoke(settingsCopy, EndInitialize, initialize);
        }
Пример #3
0
        public ICSSettings GetChildSettings(string tag, IEnumerable <Type> knownTypes)
        {
            if (settingsChildren_.ContainsKey(tag))
            {
                return(settingsChildren_[tag]);
            }
            else
            {
                var settings = new SettingsImpl(this, tag, knownTypes, Dispatcher);

                // 設定をロード
                var setTag = GetTaggedKey(settings.Tag, true);
                var setStr = Get <string>(setTag, null);
                if (setStr != null)
                {
                    using (var ms = new MemoryStream())
                        using (var writer = new StreamWriter(ms)) {
                            writer.Write(setStr);
                            writer.Flush();
                            ms.Seek(0, SeekOrigin.Begin);
                            childSettingsSerializer_.Deserialize(ms, settings);
                        }
                }

                // 子設定に追加
                settings.PropertyChanged       += settings_PropertyChanged;
                settingsChildren_[settings.Tag] = settings;
                return(settings);
            }
        }
        public void DeserializeTest(DistributedPropertySet data, ISettingsSerializer serializer)
        {
            IDistributedPropertySet result = null;
            var config = TestStartup.Configuration;

            try
            {
                result = serializer.Deserialize(serializer.Serialize(data));
            }
            catch (Exception e)
            {
                _output.WriteLine(e.ToString());
                e.Data.Keys.Cast <string>().ToList().ForEach(key => _output.WriteLine(e.Data[key].ToString()));
                throw;
            }

            Assert.NotNull(result);

            foreach (var key in data.Keys)
            {
                Assert.True(result.ContainsKey(key));
                _output.WriteLine($"{key}: {data[key]} {(data[key].Equals(result[key]) ? "==" : "!=")} {result[key]}");
                Assert.Equal(data[key], result[key]);
            }
        }
        public SettingsPresenter(ISettingsView view, ISettingsSerializer settingsSerializer)
        {
            _settingsSerializer = settingsSerializer;

            _view = view;
            _view.CurrentSettings = _settingsSerializer.Deserialize();
            _view.SettingsChanged += HandleSettingsChanged;
        }
Пример #6
0
        public SettingsPresenter(ISettingsView view, ISettingsSerializer settingsSerializer)
        {
            _settingsSerializer = settingsSerializer;

            _view = view;
            _view.CurrentSettings  = _settingsSerializer.Deserialize();
            _view.SettingsChanged += HandleSettingsChanged;
        }
        public void Deserialize_AfterSerialization_SettingsCorrect()
        {
            File.WriteAllText(TotalCommanderPath, string.Empty);
            Settings expectedSettings = new Settings
            {
                PrimaryNavigator    = Navigators.TotalCommander,
                SupportedNavigators = new List <Navigators> {
                    Navigators.TotalCommander
                },
                TotalCommanderPath = TotalCommanderPath,
                FoldersToParse     = new List <string> {
                    "D:\\temp"
                },
                ExcludeFolderTemplates = new List <string> {
                    "obj", "svn"
                },
                GlobalKeyCombination = Keys.Shift | Keys.M
            };

            _settingsSerializer.Serialize(expectedSettings);

            Settings actualSettings = _settingsSerializer.Deserialize();

            Assert.That(actualSettings.PrimaryNavigator, Is.EqualTo(expectedSettings.PrimaryNavigator));
            Assert.That(actualSettings.SupportedNavigators, Is.EquivalentTo(expectedSettings.SupportedNavigators));
            Assert.That(actualSettings.TotalCommanderPath, Is.EqualTo(expectedSettings.TotalCommanderPath));
            Assert.That(actualSettings.FoldersToParse, Is.EquivalentTo(expectedSettings.FoldersToParse));
            Assert.That(actualSettings.ExcludeFolderTemplates, Is.EquivalentTo(expectedSettings.ExcludeFolderTemplates));
            Assert.That(actualSettings.GlobalKeyCombination, Is.EqualTo(expectedSettings.GlobalKeyCombination));
        }
Пример #8
0
        public void TestDeserialize()
        {
            ISettingsSerializer json = SettingsSerializerFactory.Get("JSON");
            SettingsElement     root = createTestElement();

            SettingsElement deserialized = json.Deserialize(Expected);

            Assert.IsTrue(deserialized.FontFamily == root.FontFamily);
            Assert.IsTrue(deserialized.ScrollbackLines == root.ScrollbackLines);
            Assert.IsTrue(deserialized.DefaultProfile.FullName == root.DefaultProfile.FullName);
            Assert.IsTrue(deserialized.Networks.First().UserProfile.FullName ==
                          root.Networks.First().UserProfile.FullName);
        }
Пример #9
0
 public void Load()
 {
     try
     {
         string data = File.ReadAllText(SettingsFilePath);
         RootElement = _serializer.Deserialize(data);
     }
     catch (Exception ex) when(ex is FileNotFoundException || ex is DirectoryNotFoundException)
     {
         InitializeDefaults();
         Save();
     }
 }
        public TrayIconPresenter(ITrayView view, ISettingsSerializer settingsSerializer)
        {
            _settingsSerializer = settingsSerializer;
            _view = view;
            _view.CurrentSettings = _settingsSerializer.Deserialize();

            _view.ExitClicked += HandleExitClicked;
            _view.SettingsChanged += HandleSettingsChanged;
            _view.ShowMainClicked += HandleShowMainClicked;
            _view.ShowSettingsClicked +=HandleShowSettingsClicked;

            //Show tray icon at once
            _view.ShowView();
        }
        public TrayIconPresenter(ITrayView view, ISettingsSerializer settingsSerializer)
        {
            _settingsSerializer = settingsSerializer;
            _view = view;
            _view.CurrentSettings = _settingsSerializer.Deserialize();

            _view.ExitClicked         += HandleExitClicked;
            _view.SettingsChanged     += HandleSettingsChanged;
            _view.ShowMainClicked     += HandleShowMainClicked;
            _view.ShowSettingsClicked += HandleShowSettingsClicked;

            //Show tray icon at once
            _view.ShowView();
        }
        public async Task <T> GetSetting <T>()
        {
            var name = GetSettingNameAttribute(typeof(T));

            using (var connection = new ConScope(_dataService))
            {
                var setting = await connection.Connection.SingleAsync(connection.Connection.From <SettingV1>().Where(x => x.Name == name));

                if (setting == null || string.IsNullOrEmpty(setting.Settings))
                {
                    return((T)Activator.CreateInstance(typeof(T)));
                }
                return(_settingsSerializer.Deserialize <T>(setting.Settings));
            }
        }
Пример #13
0
        public void Restore()
        {
            Databases = new List <Database>();
            var data = Keeper.Load();

            if (data.Length > 0)
            {
                try {
                    var st = Serializer.Deserialize(data);
                    Databases = st.Databases;
                    // st.SelectedDatabase is not the one of st.Databases
                    SelectedDatabase = Databases.FirstOrDefault(w => w.Name == st.SelectedDatabase.Name);
                } catch (Exception ex) {
                    _Logger.Log(ex.Message, ex);
                }
            }
        }