Пример #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);
        }
Пример #2
0
        protected static bool HasLocalOverride <T>(
            [NotNull] CentralizableSetting <T> centralizableSetting,
            [NotNull] string settingDescription,
            [CanBeNull] NotificationCollection notifications) where T : struct
        {
            if (centralizableSetting.IsLocalOverrideDifferentFromCentralValue())
            {
                NotificationUtils.Add(notifications, "{0} ({1})", settingDescription,
                                      centralizableSetting.CurrentValue);
                return(true);
            }

            return(false);
        }