Esempio n. 1
0
        internal bool IsMatching(StateConfiguration stateConfigurationRhs, Region subRegionToCompare)
        {
            bool  isSameAs;
            State stateLhs = this.GetState(subRegionToCompare);
            State stateRhs = stateConfigurationRhs.GetState(subRegionToCompare);

            if ((stateLhs != State.Wildcard) && (stateRhs != State.Wildcard))
            {
                if (stateLhs == stateRhs)
                {
                    isSameAs = true;

                    // Bear in mind that stateLhs and stateRhs are identical,
                    // thus it doesn't matter which of two state's Regions list we take for checking the subregions
                    foreach (Region subRegion in stateLhs.Regions)
                    {
                        isSameAs = this.IsMatching(stateConfigurationRhs, subRegion);
                        if (!isSameAs)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    isSameAs = false;
                }
            }
            else
            {
                isSameAs = true;
            }

            return(isSameAs);
        }
Esempio n. 2
0
        private void InitializeAndResolve(
            StateConfiguration stateConfigurationTarget,
            Region region,
            State[] historyStatesRepository)
        {
            // Copy the model's states to the target. If the target is a wildcard, then complete the
            // information by looking in the history states or setting it to the initial state of this region

            State state = stateConfigurationTarget.GetState(region);

            if (state == State.Wildcard)
            {
                if (region.HasHistory)
                {
                    // Use previously stored history state
                    state = historyStatesRepository[region.HistoryIndex];
                }
                else
                {
                    // Use initial state
                    state = region.InitialState;
                }
            }

            if (state == null)
            {
                // Logical error: All StateConfigurationIndex elements have to be filled with valid state references
                throw new InvalidOperationException("Internal error: Either state configuration or initial state/history state not properly initialized.");
            }

            m_states[region.StateConfigurationIndex] = state;

            // Recurse to substates
            foreach (Region subRegion in state.Regions)
            {
                this.InitializeAndResolve(stateConfigurationTarget, subRegion, historyStatesRepository);
            }
        }