Esempio n. 1
0
        public static void Initialize(PreferenceStore preferenceStore)
        {
            if (initializedPreferenceStore != null)
            {
                throw new InvalidOperationException(
                          $"{nameof(PreferenceStore)} has already been initialized with " +
                          initializedPreferenceStore.GetType().FullName);
            }

            initializedPreferenceStore = preferenceStore;
        }
Esempio n. 2
0
 public Preference(
     PreferenceStore preferenceStore,
     string key,
     T defaultValue          = default,
     TypeConverter converter = null)
 {
     this.preferenceStore = preferenceStore;
     Key = key
           ?? throw new ArgumentNullException(nameof(key));
     DefaultValue   = defaultValue;
     type           = typeof(T);
     typeCode       = Type.GetTypeCode(type);
     this.converter = converter
                      ?? TypeDescriptor.GetConverter(type);
 }
Esempio n. 3
0
 /// <summary>
 /// Strictly for unit tests. Do not use elsewhere!
 /// </summary>
 internal static void InitializeForUnitTests(PreferenceStore preferenceStore)
 => initializedPreferenceStore = preferenceStore;
 public void CreateAndInitialize()
 => PreferenceStore.Initialize(Create());