コード例 #1
0
        // Private  methods
        private static FeatureSelectionStates GetNextSelectionStateOnToggle(FeatureSelectionStates currentSelectionState)
        {
            FeatureSelectionStates nextSelectionState = FeatureSelectionStates.Unselected;

            switch (currentSelectionState)
            {
            case FeatureSelectionStates.Unselected:
                nextSelectionState = FeatureSelectionStates.Selected;
                break;

            case FeatureSelectionStates.Selected:
                nextSelectionState = FeatureSelectionStates.Deselected;
                break;

            case FeatureSelectionStates.Deselected:
                nextSelectionState = FeatureSelectionStates.Unselected;
                break;
            }
            return(nextSelectionState);
        }
コード例 #2
0
        // Public methods
        public List <FeatureSelection> ToggleFeatureAsUser(string featureIdentifier)
        {
            // Variables
            FeatureSelection       toggledFeatureSelection = this.configurationInstance.FeatureSelections.Single(f => f.FeatureIdentifier == featureIdentifier);
            FeatureSelectionStates newSelectionState       = GetNextSelectionStateOnToggle(toggledFeatureSelection.SelectionState);


            // Set the new selectionState, adding it as a decision to the SolverContext
            switch (newSelectionState)
            {
            // Assert-decision  -> Selected
            case FeatureSelectionStates.Selected:
                solverContext.AddOrModifyDecisionAssumption(toggledFeatureSelection.FeatureIdentifier, true, typeof(FeatureSelection));
                toggledFeatureSelection.SelectionState = FeatureSelectionStates.Selected;
                toggledFeatureSelection.ToggledByUser  = true;
                break;

            // Assert-decision  -> Deselected
            case FeatureSelectionStates.Deselected:
                solverContext.AddOrModifyDecisionAssumption(toggledFeatureSelection.FeatureIdentifier, false, typeof(FeatureSelection));
                toggledFeatureSelection.SelectionState = FeatureSelectionStates.Deselected;
                toggledFeatureSelection.ToggledByUser  = true;
                break;

            // Retract-decision  -> Unselected
            case FeatureSelectionStates.Unselected:
                solverContext.RemoveDecisionAssumption(toggledFeatureSelection.FeatureIdentifier, typeof(FeatureSelection));
                toggledFeatureSelection.SelectionState = FeatureSelectionStates.Unselected;
                toggledFeatureSelection.ToggledByUser  = false;
                break;
            }

            // Call feedback algorithm and then recalculate all custom functions
            List <FeatureSelection> changedFeatureSelections = new List <FeatureSelection>();
            bool decisionIsValid = ApplyFeedbackAlgorithm(ref changedFeatureSelections);

            RecalculateCustomFunctions(ref changedFeatureSelections);

            //
            return(changedFeatureSelections);
        }