Exemplo n.º 1
0
 /** 添加父记录 */
 public void addParent(FactoryClassInfo cls)
 {
     cls.methodDic.forEach((k, v) =>
     {
         parentMethodDic.put(k, v);
     });
 }
Exemplo n.º 2
0
        /** 读一个工厂类 */
        public static FactoryClassInfo readFactory(string path)
        {
            string clsStr = FileUtils.readFileForUTF(path);

            FactoryClassInfo re = new FactoryClassInfo();

            re.clsStr     = clsStr;
            re.startIndex = clsStr.IndexOf('{') + 1;

            Regex reg1 = new Regex("public (virtual|override) (.*?) create(.*?)\\(\\)");
            Regex reg2 = new Regex("return new (.*?)\\(\\);");

            Match match1 = reg1.Match(clsStr);
            Match match2 = reg2.Match(clsStr);

            while (match1.Success)
            {
                FMethod method = new FMethod();
                method.isOverride = match1.Groups[1].Value.Equals("override");
                method.name       = match1.Groups[3].Value;
                method.returnType = match1.Groups[2].Value;
                method.useClsName = match2.Groups[1].Value;

                re.toAddMethod(method);

                match1 = match1.NextMatch();
                match2 = match2.NextMatch();
            }

            return(re);
        }