Beispiel #1
0
        public Preference([NotNull] string name, [NotNull] IConfigurationElement <T> defaultPreference, [NotNull] IPreferencesStore preferencesStore)
        {
            Name = name ?? throw new ArgumentNullException(nameof(name));
            _DefaultPreference = defaultPreference ?? throw new ArgumentNullException(nameof(defaultPreference));
            _PreferencesStore  = preferencesStore ?? throw new ArgumentNullException(nameof(preferencesStore));

            Reload();
        }
Beispiel #2
0
        /// <summary>
        /// Создание экземпляра класса <see cref="Preferences"/>
        /// </summary>
        /// <param name="key">Идентификатор настроек</param>
        /// <param name="preferencesStore">Хранилище настроек</param>
        /// <param name="throwIfNotFound">Если true, то генерируется исключение при получении настроек из хранилища</param>
        internal Preferences(string key, IPreferencesStore preferencesStore, bool throwIfNotFound)
        {
            _key = key ?? throw new ArgumentNullException(nameof(key));
            _preferencesStore = preferencesStore ?? throw new ArgumentNullException(nameof(preferencesStore));

            var preferencesJson = _preferencesStore.GetPreferences(key);

            if (throwIfNotFound && preferencesJson == null)
            {
                throw new PreferencesNotFoundException($"Preferences with key \"{key}\" is not found");
            }
            _preferencesJson = preferencesJson != null?JObject.Parse(preferencesJson) : new JObject();
        }
Beispiel #3
0
 public PreferencesManager([NotNull] IConfiguration configuration, [NotNull] IPreferencesStore preferencesStore, [NotNull] IWeakCache <string, object> preferencesCache)
 {
     _Configuration    = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _PreferencesStore = preferencesStore ?? throw new ArgumentNullException(nameof(preferencesStore));
     _PreferencesCache = preferencesCache ?? throw new ArgumentNullException(nameof(preferencesCache));
 }
Beispiel #4
0
 /// <summary>
 /// Создание экземпляра класса <see cref="PreferencesService"/>
 /// </summary>
 /// <param name="preferencesStore"></param>
 public PreferencesService(IPreferencesStore preferencesStore)
 {
     _preferencesStore = preferencesStore ?? throw new ArgumentNullException(nameof(preferencesStore));
 }