Exemplo n.º 1
0
        /// <summary>
        /// 获取Service类通用代码
        /// </summary>
        /// <returns></returns>
        public static string GetServiceCode()
        {
            ScriptBuildHelp build     = new ScriptBuildHelp();
            string          className = ToolData.serviceName + ToolData.servicePostfix;

            build.WriteUsing("Game.Interface");
            build.WriteEmptyLine();
            build.WriteNameSpace(ToolData.namespaceBase + "." + ToolData.servicePostfix);
            build.WriteEmptyLine();
            build.IndentTimes++;
            build.WriteInterface("I" + className, "IInitService");
            build.ToContentEnd();

            build.WriteEmptyLine();
            //class
            build.WriteClass(className, "I" + className);
            var keyName = new List <string>();

            keyName.Add("void");
            build.IndentTimes++;
            //Init
            build.WriteFun("Init", ScriptBuildHelp.Public, keyName, "", "Contexts contexts");
            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine("//contexts.service.SetGameService" + className + "(this);", true);
            build.IndentTimes--;
            build.ToContentEnd();
            build.WriteEmptyLine();

            var key = new List <string>();

            key.Add("int");
            //GetPriority
            build.WriteFun("GetPriority", ScriptBuildHelp.Public, key);
            build.BackToInsertContent();
            build.IndentTimes++;
            build.WriteLine("return 0;", true);
            build.IndentTimes--;
            build.ToContentEnd();
            return(build.ToString());
        }