Пример #1
0
        /// <summary>
        /// Returns true is values from this scopes can be applied for specific another scope.
        /// Generally true says that this scope is less restrictive than passed in scope.
        /// For instance,
        ///     (STAGE, null, null) applicable to (STATE, TST_APP, null), but not otherwise;
        ///     (null, A, null) applicable to (null, A, INST_1), but not otherwise;
        ///     (DEV, null, null) not applicable to (QA, null, null) and the opposite;
        /// </summary>
        internal bool IsApplicableTo(ConfigSettingScope anotherScope)
        {
            // alg:
            // for x in (Environment, App, AppInstance) in order check that
            // x is null or the same with passed in scope
            //
            // if at least one condition is not met, then return false
            // otherwise true;

            return((!IsEnvironmentBound || Environment == anotherScope.Environment) &&
                   (!IsAppBound || App == anotherScope.App) &&
                   (!IsAppInstanceBound || AppInstance == anotherScope.AppInstance));
        }
Пример #2
0
        /// <summary>
        /// Calculates "intersection" between scopes. If consider scope as set of filters and restrictions
        /// then "intersection" of scopes is equally or more restrictive filter that is subset of both.
        /// Lack of "intersection" means that conditions/filters are not compatible.
        ///
        /// Example:
        ///     (DEV, null, null) intersection (null, APP1, null)   = (DEV, APP1, null)
        ///     (DEV, null, null) intersection (QA, null, null)     = null
        ///     (DEV, APP1, null) intersection (null, APP1, null)   = (DEV, APP1, null)
        /// </summary>
        public static ConfigSettingScope?Intersect(ConfigSettingScope s1, ConfigSettingScope s2)
        {
            if (s1.IsEnvironmentBound && s2.IsEnvironmentBound && s1.Environment != s2.Environment ||
                s1.IsAppBound && s2.IsAppBound && s1.App != s2.App ||
                s1.IsAppInstanceBound && s2.IsAppInstanceBound && s1.AppInstance != s2.AppInstance)
            {
                return(null);
            }

            return(new ConfigSettingScope()
            {
                Environment = s1.Environment ?? s2.Environment,
                App = s1.App ?? s2.App,
                AppInstance = s1.AppInstance ?? s2.AppInstance,
            });
        }
Пример #3
0
 public ConfigClient(ConfigStoreBase configStore, ConfigSettingScope scope)
     : base(configStore, scope)
 {
 }