Exemple #1
0
        /// <summary>
        /// 子状態をIDで参照
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private FormState GetChildStateById(String id)
        {
            FormState value = null;

            return(stateMap.TryGetValue(id, out value) ? value : null);
        }
Exemple #2
0
        /// <summary>
        /// 指定された状態パスに相当する状態のインスタンスを取得する。
        /// </summary>
        /// <param name="statePathString"></param>
        /// <returns></returns>
        private FormState GetState(String statePathString)
        {
            FormState state = null;

            if (statePathString == FormState.NEXT_STATE_ID)
            {
                FormState tempState = currState;
                while (state == null)
                {
                    //現在の状態の次の状態を取得
                    if (tempState.ParentState == null)
                    {
                        //親状態がない場合は状態遷移しない。
                        state = currState;
                    }
                    else
                    {
                        //親オブジェクトの中で現在状態の次の状態を取得
                        state = tempState.ParentState.GetChildStateByIndex(tempState.Index + 1);
                        if (state == null)
                        {
                            //次の状態がない場合、親状態へ移動。
                            tempState = tempState.ParentState;
                        }
                    }
                }
            }
            else
            {
                statePathString += "/";
                char[] chars      = statePathString.ToCharArray();
                int    startIndex = 0;
                if (chars[startIndex] == '/')
                {
                    state = this;
                    startIndex++;
                }
                else
                {
                    state = currState;
                }
                int    length      = statePathString.Length;
                String pathElement = "";
                for (int i = startIndex; i < length; i++)
                {
                    if (chars[i] == '/')
                    {
                        if (pathElement == "")
                        {
                            state = null;
                            break;
                        }
                        else if (pathElement != ".")
                        {
                            if (pathElement == "..")
                            {
                                state = state.ParentState;
                            }
                            else
                            {
                                state = state.GetChildStateById(pathElement);
                            }
                        }
                        pathElement = "";
                        if (state == null)
                        {
                            break;
                        }
                    }
                    else
                    {
                        pathElement += chars[i];
                    }
                }
            }
            if (state != null)
            {
                //この時点での状態に子状態がある場合は最初の子状態を遷移先とする。
                state = GetFirstState(state);
                logger.Debug("GetState(\"" + statePathString + "\") 遷移先: " + state.GetCanonicalPath());
            }
            else
            {
                logger.Debug("GetState(\"" + statePathString + "\") 遷移先: null");
            }
            return(state);
        }