コード例 #1
0
    private void CreateCustomClass()
    {
        string structName = FindWord();

        if (string.IsNullOrEmpty(structName))
        {
            throw new System.Exception("结构名为空");
        }
        CustomStuct newStuct = new CustomStuct(structName);

        mCustomStucts.Add(newStuct);
        outPutLines += "\n" + (string.Format("    public class {0}", structName) + "\n    {");
        ProcessAngleBraket();
        while (index < mSrcText.Length)
        {
            char c = mSrcText[index];
            index++;
            if (c == '}' || c == ';')
            {
                break;
            }
            char[] stopTokens = new[] { '}' };
            string varType    = FindWord(stopTokens);
            if (string.IsNullOrEmpty(varType) == false)
            {
                if (IsValidVarType(varType))
                {
                    string varName = FindWord();
                    outPutLines += "\n" + (string.Format("       public {0}  {1} ;", varType, varName));
                    newStuct.properties.Add(new PropertyPair(varType, varName));
                }
                else
                {
                    throw new Exception(string.Format("变量类型{0}不合法", varType));
                }
            }
        }
        outPutLines += ("\n    }");
    }
コード例 #2
0
 private void CreateCustomClass()
 {
     string structName = FindWord();
     if (string.IsNullOrEmpty(structName))
     {
         throw new System.Exception("结构名为空");
     }
     CustomStuct newStuct = new CustomStuct(structName);
     mCustomStucts.Add(newStuct);
     outPutLines += "\n" + (string.Format("    public class {0}", structName) + "\n    {");
     ProcessAngleBraket();
     while (index < mSrcText.Length)
     {
         char c = mSrcText[index];
         index++;
         if (c == '}' || c == ';')
         {
             break;
         }
         char[] stopTokens = new[] { '}' };
         string varType = FindWord(stopTokens);
         if (string.IsNullOrEmpty(varType) == false)
         {
             if (IsValidVarType(varType))
             {
                 string varName = FindWord();
                 outPutLines += "\n" + (string.Format("       public {0}  {1} ;", varType, varName));
                 newStuct.properties.Add(new PropertyPair(varType, varName));
             }
             else
             {
                 throw new Exception(string.Format("变量类型{0}不合法", varType));
             }
         }
     }
     outPutLines += ("\n    }");
 }