Esempio n. 1
0
        protected CentralizableSetting <T> InitializeSetting <T>(
            [NotNull] PropertyInfo overridableSettingPropertyInfo,
            T?factoryDefault)
            where T : struct
        {
            OverridableSetting <T> centralSetting =
                CentralOptions?.GetOverridableSetting <T>(overridableSettingPropertyInfo);

            // NOTE: only initialize local setting with a value if central setting is null
            //		 or change behavior in CentralizedSetting to return the central value
            //		 even if a local value is defined.
            T?initialSettingIfLocalSettingIsNull =
                centralSetting == null
                                        ? factoryDefault
                                        : null;

            OverridableSetting <T> localSetting =
                LocalOptions.GetOverridableSetting(overridableSettingPropertyInfo,
                                                   initialSettingIfLocalSettingIsNull);

            var result = new CentralizableSetting <T>(centralSetting, localSetting,
                                                      factoryDefault);

            return(result);
        }
        public CentralizableSetting(
            [CanBeNull] OverridableSetting <T> centralSetting,
            [NotNull] OverridableSetting <T> localSetting,
            T?factoryDefault)
        {
            Assert.ArgumentNotNull(localSetting, nameof(localSetting));

            _centralSetting = centralSetting;
            _localSetting   = localSetting;
            FactoryDefault  = factoryDefault;
        }
Esempio n. 3
0
 public void SetOverridableSetting <T>([NotNull] PropertyInfo propertyInfo,
                                       [NotNull] OverridableSetting <T> value)
     where T : struct
 {
     propertyInfo.SetValue(this, value, null);
 }
Esempio n. 4
0
 protected static OverridableSetting <T> TryClone <T>(
     [CanBeNull] OverridableSetting <T> setting) where T : struct
 {
     return(setting?.Clone());
 }