コード例 #1
0
ファイル: Program.cs プロジェクト: denghe/xxlib_codegens
    public static void Gen(GenTypes genTypes, string rootNamespace, string outPath, Assembly asm)
    {
        // 提示:生成时, md5 部分内容用 GenUtils.MD5PlaceHolder 占位. 存盘时会被替换为真正 md5

        var gt = (int)genTypes;

        if ((gt & (int)GenTypes.CppClass) > 0)
        {
            if (!GenTypeId.Gen(asm, outPath, rootNamespace))
            {
                TipsAndExit("生成停止:" + rootNamespace + "_TypeIdMappings.cs 已生成. 请将其放入 源码文件或目录清单 并再次生成. ");
            }
            GenCPP_Class.Gen(asm, outPath, rootNamespace);
        }
        if ((gt & (int)GenTypes.CppClassLite) > 0)
        {
            GenCPP_Class_Lite.Gen(asm, outPath, rootNamespace);
        }
        if ((gt & (int)GenTypes.CppClassFilter) > 0)
        {
            if (!GenTypeId.Gen(asm, outPath, rootNamespace))
            {
                TipsAndExit("生成停止:" + rootNamespace + "_TypeIdMappings.cs 已生成. 请将其放入 源码文件或目录清单 并再次生成. ");
            }
            GenCPP_Class.Gen(asm, outPath, rootNamespace, new TemplateLibrary.Filter <TemplateLibrary.CppFilter>(asm));
        }
        if ((gt & (int)GenTypes.CppSqlite) > 0)
        {
            if (!GenTypeId.Gen(asm, outPath, rootNamespace))
            {
                TipsAndExit("生成停止:" + rootNamespace + "_TypeIdMappings.cs 已生成. 请将其放入 源码文件或目录清单 并再次生成. ");
            }
            GenCPP_SQLite.Gen(asm, outPath, rootNamespace);
        }
        if ((gt & (int)GenTypes.CSharpClass) > 0)
        {
            //if (!GenTypeId.Gen(asm, outPath, rootNamespace)) {
            //    TipsAndExit("生成停止:" + rootNamespace + "_TypeIdMappings.cs 已生成. 请将其放入 源码文件或目录清单 并再次生成. ");
            //}
            GenCS_Class.Gen(asm, outPath, rootNamespace);
        }
        if ((gt & (int)GenTypes.CSharpMySql) > 0)
        {
            if (!GenTypeId.Gen(asm, outPath, rootNamespace))
            {
                TipsAndExit("生成停止:" + rootNamespace + "_TypeIdMappings.cs 已生成. 请将其放入 源码文件或目录清单 并再次生成. ");
            }
            GenCS_MySql.Gen(asm, outPath, rootNamespace);
        }
        if ((gt & (int)GenTypes.LuaClassFilter) > 0)
        {
            if (!GenTypeId.Gen(asm, outPath, rootNamespace))
            {
                TipsAndExit("生成停止:" + rootNamespace + "_TypeIdMappings.cs 已生成. 请将其放入 源码文件或目录清单 并再次生成. ");
            }
            GenLUA_Class.Gen(asm, outPath, rootNamespace, new TemplateLibrary.Filter <TemplateLibrary.LuaFilter>(asm));
        }
        // ...
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: FJSDS/xxlib_cpp
    static void Main(string[] args)
    {
#if !DEBUG
        global::System.Console.WriteLine("please run generater in debug mode!");
        global::System.Console.ReadKey();
        return;
#endif
        var outPath = args.Length > 0 ? args[0] : outputPath;

        // 扫所有添加过引用的, 名字前缀为 templatePrefix 的 dll, 执行相应的生成
        foreach (var fn in Directory.GetFiles(Application.StartupPath, templatePrefix + "*.dll"))
        {
            var md5     = File.ReadAllBytes(fn).GetMD5();
            var asm     = Assembly.LoadFile(fn);
            var shortfn = new FileInfo(fn).Name;
            shortfn = shortfn.Substring(0, shortfn.LastIndexOf('.'));
            var path = Path.Combine(Application.StartupPath, outPath);
            var tn   = shortfn.Substring(templatePrefix.Length);

            if (!GenTypeId.Gen(asm, path, tn))
            {
                System.Console.WriteLine(tn + "_TypeIdMappings.cs 已生成. 请将其放入模板项目并再次生成. ");
                continue;
            }

            GenCPP_Class.Gen(asm, path, tn, md5);
            GenCPP_Class.Gen(asm, path, tn, md5, new TemplateLibrary.Filter <TemplateLibrary.CppFilter>(asm));

            GenCPP_SQLite.Gen(asm, path, tn);

            GenLUA_Class.Gen(asm, path, tn, md5);

            GenCS_Class.Gen(asm, path, tn, md5);
            GenCS_MySql.Gen(asm, path, tn);
        }
    }