Esempio n. 1
0
        public bool KnocksSomeButNotAll(NodeLUISPhoneDialog.EIntents desiredFeature)
        {
            Dictionary <NodeLUISPhoneDialog.EIntents, NumberOfDifferent> enumerated = new Dictionary <NodeLUISPhoneDialog.EIntents, NumberOfDifferent>()
            {
                { NodeLUISPhoneDialog.EIntents.Color, () => handSets.GetBagColors().Count },
                { NodeLUISPhoneDialog.EIntents.Brand, () => handSets.GetBagBrands().Count },
                { NodeLUISPhoneDialog.EIntents.OS, () => handSets.GetBagOSes().Count }
            };
            Predicate <HandSetFeatures> predicate;
            int count = handSets.BagCount();
            int knockOutNumber;

            if (booleanFilters.TryGetValue(desiredFeature, out predicate))  // It's boolean
            {
                knockOutNumber = handSets.KnockOutNumber(predicate);
                return((knockOutNumber != count) && (knockOutNumber != 0));
            }
            else if (intentFilters.TryGetValue(desiredFeature, out predicate))
            {
                if (!enumerated.ContainsKey(desiredFeature))
                {
                    double highStandardThreshold;

                    intent = desiredFeature;
                    highStandardThreshold = handSets.GetHighStandardThreshold(this, getters[desiredFeature]);
                    if (desiredFeature == NodeLUISPhoneDialog.EIntents.Newest)
                    {
                        DateThreshold = new DateTime((long)highStandardThreshold);
                    }
                    else
                    {
                        Threshold = highStandardThreshold;
                    }
                    knockOutNumber = handSets.KnockOutNumber(predicate);
                    return((knockOutNumber != count) && (knockOutNumber != 0));
                }
                else
                {
                    return((enumerated[desiredFeature])() != 1);
                }
            }
            throw new Exception("Error...received a feature I don't know about:" + desiredFeature.ToString());
        }