public static Dictionary <string, string> GetNonAmbiguousConditionContracts(ConditionEvaluationStateImpl state)
        {
            var res = new Dictionary <string, string>();

            // it makes little sense for condition to be that short
            if (state.Condition.Length < 2)
            {
                return(res);
            }

            // in case we don't know what some part of the condition does - don't make any assumptions at all
            if (state.UnsupportedNodes.Count > 0)
            {
                return(res);
            }

            foreach (var keyValuePair in GetConditionValues(state))
            {
                if (keyValuePair.Value.Count != 1)
                {
                    continue;
                }

                res.Add(keyValuePair.Key, keyValuePair.Value[0]);
            }

            return(res);
        }
        public static Dictionary <string, List <string> > GetConditionValues(ConditionEvaluationStateImpl state)
        {
            if (state.Evaluated)
            {
                return(state.ConditionedPropertiesInProject);
            }

            state.Evaluate();

            return(state.ConditionedPropertiesInProject);
        }
        private static bool TryGetCachedOrCreateState(string condition, out ConditionEvaluationStateImpl state)
        {
            if (Cache.TryGetValue(condition, out state))
            {
                return(true);
            }

            state = new ConditionEvaluationStateImpl();

            Cache.Add(condition, state);

            return(false);
        }
        private static bool TryGetCachedOrCreateState(string condition, out ConditionEvaluationStateImpl state)
        {
            state = MemoryCache.Default[condition] as ConditionEvaluationStateImpl;

            if (state != null)
            {
                return(true);
            }

            state = new ConditionEvaluationStateImpl();

            MemoryCache.Default.Add(condition, state, ObjectCache.InfiniteAbsoluteExpiration);

            return(false);
        }
Exemplo n.º 5
0
        public static Dictionary <string, string> GetNonAmbiguousConditionContracts(ConditionEvaluationStateImpl state)
        {
            var res = new Dictionary <string, string>();

            // it makes little sense for condition to be that short
            if (state.Condition.Length < 2)
            {
                return(res);
            }

            foreach (var keyValuePair in GetConditionValues(state))
            {
                if (keyValuePair.Value.Count != 1)
                {
                    continue;
                }

                res.Add(keyValuePair.Key, keyValuePair.Value[0]);
            }

            return(res);
        }