/// <summary> /// 生成委托声明 /// </summary> /// <param name="delegateInfos"></param> private static void GeneratorDeledateStatements(Dictionary <DelegateInfo, List <ProtectMethodInfo> > delegateAndMethods) { StringBuilder mis = new StringBuilder(); foreach (var key in delegateAndMethods.Keys) { foreach (var mi in delegateAndMethods[key]) { mis.Append("public static " + key.DelegateName + " " + mi.MethodName + "__Delegate;\n\t\t\t"); } } string out_path = EditorPrefs.GetString("out_path").Replace("Adapter", "Bugfix") + "/DelegateStatements.cs"; if (File.Exists(out_path)) { File.Delete(out_path); } //模板路径 var tmpdPath = Application.dataPath + "/ThirdParty/ILRuntime/Editor/Adapter/Template/bugfix_delegate_statements.tmpd"; BugfixFileManager manager = new BugfixFileManager(tmpdPath); manager.SetKeyValue("{$Namespace}", "ILRuntime"); manager.SetKeyValue("{$DelegateStatements}", mis.ToString()); //生成文件 File.WriteAllText(out_path, manager.Generate()); }
/// <summary> /// 生成委托定义 /// </summary> /// <param name="delegateInfos"></param> private static void GeneratorDeledateDefines(List <DelegateInfo> delegateInfos) { StringBuilder content = new StringBuilder(); string returnStr = ""; foreach (var @delegate in delegateInfos) { returnStr = @delegate.ReturnTypeStr == "System.Void" ? "void" : @delegate.ReturnTypeStr; content.Append("public delegate " + returnStr + " " + @delegate.DelegateName + "(" + @delegate.Parameters + ");\n\t\t\t"); } string out_path = EditorPrefs.GetString("out_path").Replace("Adapter", "Bugfix") + "/DelegateDefines.cs"; //模板路径 var tmpdPath = Application.dataPath + "/ThirdParty/ILRuntime/Editor/Adapter/Template/bugfix_delegate_defines.tmpd"; BugfixFileManager manager = new BugfixFileManager(tmpdPath); manager.SetKeyValue("{$Namespace}", "ILRuntime"); manager.SetKeyValue("{$DelegateDefines}", content.ToString()); //生成文件 File.WriteAllText(out_path, manager.Generate()); }