Пример #1
0
        public static void gen(string strSrcDirPath, string strLevel, string strIsCheck, string strIsEnvMock)
        {
            Console.WriteLine("==============GenJSServiceMockReg start====================");

            //1.get template
            var strTemplate     = File.ReadAllText(FILE_PATH_TEMPLATE());
            var strTemplatePart = File.ReadAllText(FILE_PATH_TEMPLATE_PART());

            //2.generate parts
            var arrLines = File.ReadAllLines(FILE_PATH_PRJ_IN_X(strSrcDirPath, ""));
            var strParts = "";

            foreach (var strModuleName in arrLines)
            {
                var strFormatModuleName = ModuleNameAdapter.formatName(strModuleName, "");
                var strTmp = strTemplatePart.Replace(REPLACE_MODULE_NAME, strFormatModuleName)
                             .Replace(REPLACE_MODULELEVEL, strLevel)
                             .Replace(REPLACE_MODULEISCHECK, strIsCheck)
                             .Replace(REPLACE_MODULEISENVMOCK, strIsEnvMock);
                if (arrLines.Last() != strModuleName)
                {
                    strTmp += "," + Environment.NewLine;
                }
                strParts += strTmp;
            }

            //3.generate template
            var strRes = strTemplate.Replace(REPLACE_MODULEJSONS, strParts);

            //4.write file
            File.WriteAllText(FILE_PATH_DST(strSrcDirPath, ""), strRes);

            Console.WriteLine("==============GenJSServiceMockReg end====================");
        }
Пример #2
0
        public static void _genByType(string strSrcDirPath, string strSubDirPath, IGenFileAdapterLess oIFileAdapterLess)
        {
            var arrLines = File.ReadAllLines(FILE_PATH_PRJ_IN_X(strSrcDirPath, strSubDirPath));

            foreach (var strModuleName in arrLines)
            {
                //1.get params
                var strPrefix           = oIFileAdapterLess.getPrefixName();
                var strTemplateFilePath = oIFileAdapterLess.getTemplateFilePath();
                var strDstFilePath      = oIFileAdapterLess.getDstFilePath(strSrcDirPath, strSubDirPath, strModuleName);

                if (!File.Exists(strDstFilePath))
                {
                    //2.read template
                    var strContent = File.ReadAllText(strTemplateFilePath);

                    //3.update content
                    strContent = strContent.Replace(REPLACE_MODULE_NAME, ModuleNameAdapter.formatName(strModuleName, strPrefix));

                    //4.write content
                    File.WriteAllText(strDstFilePath, strContent);
                    Console.WriteLine("File:" + new FileInfo(strDstFilePath).Name);
                }
            }
        }
Пример #3
0
        public static string genModule(string strSrcDirPath)
        {
            //1.get walle.prj
            var strFilePathPrj = _getFilePathPrj(strSrcDirPath);
            var arrModuleNames = File.ReadAllLines(strFilePathPrj);

            //2.遍历
            var strContent = "";

            foreach (var strModuleName in arrModuleNames)
            {
                var strModuleNameFormat = ModuleNameAdapter.formatName(strModuleName, "");
                strContent += strModuleNameFormat;
                if (arrModuleNames.Last() != strModuleName)
                {
                    strContent += ",";
                    strContent += Environment.NewLine;
                }
            }

            return(strContent);
        }