public SettingsService(IDefaultValueProvider defaultValueProvider, ApplicationDataContainers containers) { _defaultValueProvider = defaultValueProvider; _localSettings = containers.LocalSettings; _roamingSettings = containers.RoamingSettings; _themes = containers.Themes; _keyBindings = containers.KeyBindings; _shellProfiles = containers.ShellProfiles; _sshProfiles = containers.SshProfiles; foreach (var theme in _defaultValueProvider.GetPreInstalledThemes()) { if (GetTheme(theme.Id) == null) { _themes.WriteValueAsJson(theme.Id.ToString(), theme); } } foreach (var shellProfile in _defaultValueProvider.GetPreinstalledShellProfiles()) { if (GetShellProfile(shellProfile.Id) == null) { _shellProfiles.WriteValueAsJson(shellProfile.Id.ToString(), shellProfile); } } }
/// <inheritdoc /> public TOptions Create(string name) { TOptions instance; if (_serviceProvider != null && _defaultValueProviders != null) { IDefaultValueProvider <TOptions> defaultValueProvider = _defaultValueProviders.GetService(_serviceProvider, name); instance = defaultValueProvider != null?defaultValueProvider.GetDefault() : ActivatorUtilities.CreateInstance <TOptions>(_serviceProvider); } else { instance = Activator.CreateInstance <TOptions>(); } foreach (IConfigureOptions <TOptions> setup in _setups) { IConfigureNamedOptions <TOptions> configureNamedOptions; if ((configureNamedOptions = setup as IConfigureNamedOptions <TOptions>) != null) { configureNamedOptions.Configure(name, instance); } else { setup.Configure(instance); } } return(instance); }
public ProfilesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; CreateShellProfileCommand = new RelayCommand(CreateShellProfile); var defaultShellProfileId = _settingsService.GetDefaultShellProfileId(); foreach (var shellProfile in _settingsService.GetShellProfiles()) { var viewModel = new ShellProfileViewModel(shellProfile, settingsService, dialogService); viewModel.Deleted += OnShellProfileDeleted; viewModel.SetAsDefault += OnShellProfileSetAsDefault; if (shellProfile.Id == defaultShellProfileId) { viewModel.IsDefault = true; } ShellProfiles.Add(viewModel); } SelectedShellProfile = ShellProfiles.First(p => p.IsDefault); }
private void SetDefaultValue(DefaultValue value) { this.defaultValue = value; this.defaultValueProvider = defaultValue == DefaultValue.Mock ? new MockDefaultValueProvider(this) : new EmptyDefaultValueProvider(); }
public CascadingSearchDefaultValueProvider( IPromptReportParameterService promptReportParameterService, IDefaultValueProvider defaultValueProvider) { _defaultValueProvider = defaultValueProvider; _promptReportParameterService = promptReportParameterService; }
public ThemesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, IThemeParserFactory themeParserFactory, IFileSystemService fileSystemService) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _themeParserFactory = themeParserFactory; _fileSystemService = fileSystemService; CreateThemeCommand = new RelayCommand(CreateTheme); ImportThemeCommand = new RelayCommand(ImportTheme); CloneCommand = new RelayCommand <ThemeViewModel>(CloneTheme); _settingsService.TerminalOptionsChanged += OnTerminalOptionsChanged; BackgroundOpacity = _settingsService.GetTerminalOptions().BackgroundOpacity; var activeThemeId = _settingsService.GetCurrentThemeId(); foreach (var theme in _settingsService.GetThemes()) { var viewModel = new ThemeViewModel(theme, _settingsService, _dialogService, fileSystemService); viewModel.Activated += OnThemeActivated; viewModel.Deleted += OnThemeDeleted; if (theme.Id == activeThemeId) { viewModel.IsActive = true; } Themes.Add(viewModel); } SelectedTheme = Themes.First(t => t.IsActive); }
public SshProfilesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IFileSystemService fileSystemService, IApplicationView applicationView, IDefaultValueProvider defaultValueProvider, ITrayProcessCommunicationService trayProcessCommunicationService) { _settingsService = settingsService; _dialogService = dialogService; _fileSystemService = fileSystemService; _applicationView = applicationView; _defaultValueProvider = defaultValueProvider; _trayProcessCommunicationService = trayProcessCommunicationService; CreateSshProfileCommand = new RelayCommand(CreateSshProfile); CloneCommand = new RelayCommand <SshProfileViewModel>(Clone); foreach (var sshProfile in _settingsService.GetSshProfiles()) { var viewModel = new SshProfileViewModel(sshProfile, settingsService, dialogService, fileSystemService, applicationView, defaultValueProvider, _trayProcessCommunicationService, false); viewModel.Deleted += OnSshProfileDeleted; SshProfiles.Add(viewModel); } if (SshProfiles.Count == 0) { CreateSshProfile(); } SelectedSshProfile = SshProfiles.First(); }
/// <summary> /// Initializes a new instance of the <see cref="OperationCopyValueIfSourceNotDefault{TSource, TTarget, TValue}"/> class. /// </summary> public OperationCopyValueIfSourceNotDefault( IDefaultValueProvider defaultValueProvider) { defaultValueProvider.NotNull(nameof(defaultValueProvider)); this.defaultValueProvider = defaultValueProvider; }
public ProfilesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, IFileSystemService fileSystemService, IApplicationView applicationView) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _fileSystemService = fileSystemService; _applicationView = applicationView; CreateShellProfileCommand = new RelayCommand(CreateShellProfile); CloneCommand = new RelayCommand <ShellProfileViewModel>(Clone); var defaultShellProfileId = _settingsService.GetDefaultShellProfileId(); foreach (var shellProfile in _settingsService.GetShellProfiles()) { var viewModel = new ShellProfileViewModel(shellProfile, settingsService, dialogService, fileSystemService, applicationView, defaultValueProvider, false); viewModel.Deleted += OnShellProfileDeleted; viewModel.SetAsDefault += OnShellProfileSetAsDefault; if (shellProfile.Id == defaultShellProfileId) { viewModel.IsDefault = true; } ShellProfiles.Add(viewModel); } SelectedShellProfile = ShellProfiles.First(p => p.IsDefault); }
public ThemesPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; CreateThemeCommand = new RelayCommand(CreateTheme); var activeThemeId = _settingsService.GetCurrentThemeId(); foreach (var theme in _settingsService.GetThemes()) { var viewModel = new ThemeViewModel(theme, _settingsService, _dialogService); viewModel.Activated += OnThemeActivated; viewModel.Deleted += OnThemeDeleted; if (theme.Id == activeThemeId) { viewModel.IsActive = true; } Themes.Add(viewModel); } SelectedTheme = Themes.First(t => t.IsActive); }
/// <summary> /// Initializes a new instance of the <see cref="OperationCopyValueWithUpperLimit{TSource, TTarget, TValue}"/> class. /// </summary> public OperationCopyValueWithUpperLimit( IDefaultValueProvider defaultValueProvider) { defaultValueProvider.NotNull(nameof(defaultValueProvider)); this.defaultValueProvider = defaultValueProvider; }
public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService, ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory) { KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService); General = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider); Shell = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider); Terminal = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider); Themes = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory); }
public MousePageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _applicationSettings = _settingsService.GetApplicationSettings(); RestoreDefaultsCommand = new RelayCommand(async() => await RestoreDefaults().ConfigureAwait(false)); }
public MousePageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _applicationSettings = _settingsService.GetApplicationSettings(); RestoreDefaultsCommand = new AsyncRelayCommand(RestoreDefaultsAsync); }
public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService, ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService, IFileSystemService fileSystemService, IStartupTaskService startupTaskService) { KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService); General = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService); Shell = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService); Terminal = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService); Themes = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService); Mouse = new MousePageViewModel(settingsService, dialogService, defaultValueProvider); }
public KeyBindingsPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, ITrayProcessCommunicationService trayProcessCommunicationService) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _trayProcessCommunicationService = trayProcessCommunicationService; RestoreDefaultsCommand = new RelayCommand(async() => await RestoreDefaults().ConfigureAwait(false)); AddCommand = new RelayCommand <string>(async command => await Add(command).ConfigureAwait(false)); Initialize(_settingsService.GetCommandKeyBindings()); }
public ShellPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; RestoreDefaultsCommand = new RelayCommand(async() => await RestoreDefaults().ConfigureAwait(false)); BrowseForCustomShellCommand = new RelayCommand(async() => await BrowseForCustomShell().ConfigureAwait(false)); BrowseForWorkingDirectoryCommand = new RelayCommand(async() => await BrowseForWorkingDirectory().ConfigureAwait(false)); _shellConfiguration = _settingsService.GetShellConfiguration(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="contentType"></param> /// <param name="oneSortOnly"></param> /// <param name="urlBuilderFactory"></param> /// <param name="defaultValueProvider"></param> public SearchContext(string contentType, bool oneSortOnly, IUrlBuilderFactory urlBuilderFactory, IDefaultValueProvider defaultValueProvider) { this.ContentType = contentType; this.m_filters = new List<IFilterPart>(); this.m_sorts = new List<ISortPart>(); this.PageSize = 20; this.PageIndex = FIRST_PAGE_INDEX; this.OneSortOnly = oneSortOnly; this.UrlBuilderFactory = urlBuilderFactory ?? new SimpleUrlBuilderFactory(); this.DefaultValueProvider = defaultValueProvider ?? new SimpleDefaultValueProvider(); this.m_result = null; }
public SshHelperService(ISettingsService settingsService, IDialogService dialogService, IFileSystemService fileSystemService, IApplicationView applicationView, IDefaultValueProvider defaultValueProvider, ITrayProcessCommunicationService trayProcessCommunicationService) { _settingsService = settingsService; _dialogService = dialogService; _fileSystemService = fileSystemService; _applicationView = applicationView; _defaultValueProvider = defaultValueProvider; _trayProcessCommunicationService = trayProcessCommunicationService; }
public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService, ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService, IFileSystemService fileSystemService, IStartupTaskService startupTaskService, IUpdateService updateService, IApplicationView applicationView, IApplicationLanguageService applicationLanguageService) { About = new AboutPageViewModel(settingsService, updateService, applicationView); KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, defaultValueProvider, trayProcessCommunicationService); General = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService, applicationLanguageService); Profiles = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService, applicationView); Terminal = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService); Themes = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService); Mouse = new MousePageViewModel(settingsService, dialogService, defaultValueProvider); SshProfiles = new SshProfilesPageViewModel(settingsService, dialogService, fileSystemService, applicationView, defaultValueProvider, trayProcessCommunicationService); }
public GeneralPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, IStartupTaskService startupTaskService, IApplicationLanguageService applicationLanguageService) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _startupTaskService = startupTaskService; _applicationLanguageService = applicationLanguageService; _applicationSettings = _settingsService.GetApplicationSettings(); RestoreDefaultsCommand = new RelayCommand(async() => await RestoreDefaults().ConfigureAwait(false)); }
public SettingsService(IDefaultValueProvider defaultValueProvider) { _defaultValueProvider = defaultValueProvider; _localSettings = ApplicationData.Current.LocalSettings; _roamingSettings = ApplicationData.Current.RoamingSettings; _themes = _roamingSettings.CreateContainer(ThemesContainerName, ApplicationDataCreateDisposition.Always); foreach (var theme in _defaultValueProvider.GetPreInstalledThemes()) { _themes.WriteValueAsJson(theme.Id.ToString(), theme); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { IDefaultValueProvider defValProvider = parameter as IDefaultValueProvider ?? SimpleDefaultValueProvider.Instance; if (defValProvider.IsDefaultValue(value, targetType, parameter, culture)) { return(defValProvider.GetDefaultValue(value, targetType, parameter, culture)); } if (value == null) { return(parameter); } return(value.ToString()); }
public SettingsViewModel(ISettingsService settingsService, IDefaultValueProvider defaultValueProvider, IDialogService dialogService, ITrayProcessCommunicationService trayProcessCommunicationService, IThemeParserFactory themeParserFactory, ISystemFontService systemFontService, IFileSystemService fileSystemService, IStartupTaskService startupTaskService, IApplicationView applicationView, IApplicationLanguageService applicationLanguageService, ApplicationDataContainers containers, IImageFileSystemService imageFileSystemService) { KeyBindings = new KeyBindingsPageViewModel(settingsService, dialogService, trayProcessCommunicationService); General = new GeneralPageViewModel(settingsService, dialogService, defaultValueProvider, startupTaskService, applicationLanguageService, trayProcessCommunicationService, fileSystemService); Profiles = new ProfilesPageViewModel(settingsService, dialogService, defaultValueProvider, fileSystemService, applicationView); Terminal = new TerminalPageViewModel(settingsService, dialogService, defaultValueProvider, systemFontService); Themes = new ThemesPageViewModel(settingsService, dialogService, defaultValueProvider, themeParserFactory, fileSystemService, imageFileSystemService); Mouse = new MousePageViewModel(settingsService, dialogService, defaultValueProvider); SshProfiles = new SshProfilesPageViewModel(settingsService, dialogService, fileSystemService, applicationView, trayProcessCommunicationService, containers.HistoryContainer); }
private static object GetInitialValue(IDefaultValueProvider valueProvider, Stack <Type> mockedTypesStack, PropertyInfo property) { if (mockedTypesStack.Contains(property.PropertyType)) { // to deal with loops in the property graph valueProvider = new EmptyDefaultValueProvider(); } else { // to make sure that properties of types that don't impelemt ISerializable properly (Castle throws ArgumentException) // are mocked with default value instead. // It will only result in exception if the properties are accessed. valueProvider = new SerializableTypesValueProvider(valueProvider); } return(valueProvider.ProvideDefault(property.GetGetMethod())); }
public GeneralPageViewModel(ISettingsService settingsService, IDialogService dialogService, IDefaultValueProvider defaultValueProvider, IStartupTaskService startupTaskService, IApplicationLanguageService applicationLanguageService, ITrayProcessCommunicationService trayProcessCommunicationService, IFileSystemService fileSystemService) { _settingsService = settingsService; _dialogService = dialogService; _defaultValueProvider = defaultValueProvider; _startupTaskService = startupTaskService; _applicationLanguageService = applicationLanguageService; _trayProcessCommunicationService = trayProcessCommunicationService; _fileSystemService = fileSystemService; _applicationSettings = _settingsService.GetApplicationSettings(); RestoreDefaultsCommand = new AsyncCommand(RestoreDefaults); BrowseLogDirectoryCommand = new AsyncCommand(BrowseLogDirectory); }
ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { IDefaultValueProvider defValProvider = parameter as IDefaultValueProvider ?? SimpleDefaultValueProvider.Instance; object def = defValProvider.GetDefaultValue(value, targetType, parameter, culture); if (def == value) { return(null); } if (def != null && def.Equals(value)) { return(null); } return(value); }
public ShellProfileViewModel(ShellProfile shellProfile, ISettingsService settingsService, IDialogService dialogService, IFileSystemService fileSystemService, IApplicationView applicationView, IDefaultValueProvider defaultValueProvider, Boolean isNew) { Model = shellProfile; _settingsService = settingsService; _dialogService = dialogService; _fileSystemService = fileSystemService; _applicationView = applicationView; _defaultValueProvider = defaultValueProvider; _isNew = isNew; _settingsService.ThemeAdded += OnThemeAdded; _settingsService.ThemeDeleted += OnThemeDeleted; TabThemes = new ObservableCollection <TabTheme>(settingsService.GetTabThemes()); TerminalThemes = new ObservableCollection <TerminalTheme> { new TerminalTheme { Id = Guid.Empty, Name = "Default" } }; foreach (var theme in _settingsService.GetThemes()) { TerminalThemes.Add(theme); } KeyBindings = new KeyBindingsViewModel(shellProfile.Id.ToString(), _dialogService, string.Empty, false); InitializeViewModelProperties(shellProfile); SetDefaultCommand = new RelayCommand(SetDefault); DeleteCommand = new AsyncCommand(Delete, CanDelete); EditCommand = new RelayCommand(Edit); CancelEditCommand = new AsyncCommand(CancelEdit); SaveChangesCommand = new RelayCommand(SaveChanges); AddKeyboardShortcutCommand = new AsyncCommand(AddKeyboardShortcut); BrowseForCustomShellCommand = new AsyncCommand(BrowseForCustomShell); BrowseForWorkingDirectoryCommand = new AsyncCommand(BrowseForWorkingDirectory); RestoreDefaultsCommand = new AsyncCommand(RestoreDefaults); }
/// <inheritdoc /> public TOptions Create(string name) { IDefaultValueProvider <TOptions> defaultValueProvider = null; //_defaultValueProviders.GetService(null, name);//todo: IDefaultValueProvider TOptions instance = defaultValueProvider != null?defaultValueProvider.GetDefault() : Activator.CreateInstance <TOptions>(); foreach (IConfigureOptions <TOptions> setup in _setups) { IConfigureNamedOptions <TOptions> configureNamedOptions; if ((configureNamedOptions = setup as IConfigureNamedOptions <TOptions>) != null) { configureNamedOptions.Configure(name, instance); } else { setup.Configure(instance); } } return(instance); }
private static void CopyDefaultValue <T>(T t, ConnectionAttribute a) where T : new() { Type dvpt = a.DefaultValueProvider; IDefaultValueProvider dvp = null; MethodInfo mi = dvpt.GetMethod("GetInstance", BindingFlags.Static | BindingFlags.Public); if (mi != null) { dvp = (IDefaultValueProvider)mi.Invoke(null, new Object[] { }); } else { ConstructorInfo ci = dvpt.GetConstructor(new Type[] { }); dvp = (IDefaultValueProvider)ci.Invoke(new Object[] { }); } Object val = dvp.GetDefaultValue(); PropertyInfo targetProperty = RetrieveTargetProperty <T>(t, a); targetProperty.GetSetMethod().Invoke(t, new Object[] { val }); }
public SerializableTypesValueProvider(IDefaultValueProvider decorated) { this.decorated = decorated; }
public EmptyPromptDefaultValueProvider(IDefaultValueProvider defaultValueProvider) { _defaultValueProvider = defaultValueProvider; }
public StrictDefaultValuesProvider(IDefaultValueProvider defaultValueProvider) { _defaultValueProvider = defaultValueProvider; }
/// <summary> /// 构造函数 /// </summary> /// <param name="contentType"></param> /// <param name="urlBuilderFactory"></param> /// <param name="defaultValueProvider"></param> public SearchContext(string contentType, IUrlBuilderFactory urlBuilderFactory, IDefaultValueProvider defaultValueProvider) : this(contentType, DEFAULT_ONE_SORT_ONLY, urlBuilderFactory, defaultValueProvider) { }