Esempio n. 1
0
        /// <summary>
        /// 解析普通代码块
        /// </summary>
        protected string AnalyticalNormal(CodeBox box)
        {
            string codeString    = "";
            string boxcodestring = "";

            switch (box.CodeBoxType)
            {
                #region 分支结构
            case CodeBox.XAType.XIf:
                string ifstring = box.GetCLanguagesCodeBoxValue();
                codeString += "if ( " + ifstring + "== true )" + LineBreaks;
                codeString += "{" + LineBreaks;
                ///条件为真的出口
                XAribute trueExc = (XAribute)box.RightAribute.Children[0];
                ///如果有后续内容
                if (trueExc.GetMyBeziers.Count > 0)
                {
                    codeString += AnalyticalCenterTool(trueExc);
                }
                codeString += LineBreaks;
                codeString += "}" + LineBreaks;
                codeString += "else" + LineBreaks;
                codeString += "{" + LineBreaks;
                ///条件为假的出口
                XAribute falseExc = (XAribute)box.RightAribute.Children[1];
                ///如果有后续内容
                if (falseExc.GetMyBeziers.Count > 0)
                {
                    codeString += AnalyticalCenterTool(falseExc);
                }
                codeString += LineBreaks;
                codeString += "}" + LineBreaks;
                break;

                #endregion
                #region 循环结构
            case CodeBox.XAType.XFor:
                boxcodestring = box.GetCLanguagesCodeBoxValue();
                codeString   += "for ( " + boxcodestring + " )" + LineBreaks;
                codeString   += "{" + LineBreaks;
                List <XAribute> butes = box.GetRightExc();
                ///如果有后续内容
                if (butes[0].GetMyBeziers.Count > 0)
                {
                    codeString += AnalyticalCenterTool(butes[0]);
                }
                codeString += "}" + LineBreaks;
                if (butes[1].GetMyBeziers.Count > 0)
                {
                    codeString += AnalyticalCenterTool(butes[1]);
                }
                break;

                #endregion
                #region 顺序结构
            default:
                codeString += box.GetCLanguagesCodeBoxValue() + LineBreaks;
                foreach (XAribute bute in box.RightAribute.Children)
                {
                    if (bute.SelectType == XAribute.XAttributeType.XExc)
                    {
                        if (bute.GetMyBeziers.Count > 0)
                        {
                            codeString += AnalyticalCenterTool(bute);
                        }
                    }
                }
                break;
                #endregion
            }
            return(codeString);
        }