Ejemplo n.º 1
0
 /// <summary>
 /// 检测
 /// </summary>
 public void Check()
 {
     ImportXlsxAbsolutePath = System.IO.Path.GetFullPath(XlsxManager.GetToolRootPath() + ImportXlsxRelativePath);
     foreach (var item in configData.CodeConfigDataMap)
     {
         item.Value.ExportXmlAbsolutePath  = System.IO.Path.GetFullPath(XlsxManager.GetToolRootPath() + item.Value.ExportXmlRelativePath);
         item.Value.ExportCodeAbsolutePath = System.IO.Path.GetFullPath(XlsxManager.GetToolRootPath() + item.Value.ExportCodeRelativePath);
         if (!File.Exists(XlsxManager.GetToolRootPath() + item.Value.RecorderTemplateFileRelativePath))
         {
             XlsxManager.Log(false, $"代码类:{item.Key}缺少Recorder模板!");
         }
         else
         {
             using (StreamReader streamReader = new StreamReader(XlsxManager.GetToolRootPath() + item.Value.RecorderTemplateFileRelativePath))
             {
                 item.Value.RecorderTemplateContent = streamReader.ReadToEnd();
             }
         }
         if (!File.Exists(XlsxManager.GetToolRootPath() + item.Value.EnumTemplateFileRelativePath))
         {
             XlsxManager.Log(false, $"代码类:{item.Key}缺少CSEnum模板!");
         }
         else
         {
             using (StreamReader streamReader = new StreamReader(XlsxManager.GetToolRootPath() + item.Value.EnumTemplateFileRelativePath))
             {
                 item.Value.EnumTemplateContent = streamReader.ReadToEnd();
             }
         }
         if (!File.Exists(XlsxManager.GetToolRootPath() + item.Value.StructTemplateFileRelativePath))
         {
             XlsxManager.Log(false, $"代码类:{item.Key}缺少CSStruct模板!");
         }
         else
         {
             using (StreamReader streamReader = new StreamReader(XlsxManager.GetToolRootPath() + item.Value.StructTemplateFileRelativePath))
             {
                 item.Value.StructTemplateContent = streamReader.ReadToEnd();
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载
        /// </summary>
        void Load()
        {
            if (!File.Exists(configPath))
            {
                XlsxManager.Log(false, $"配置文件不存在!{configPath}");
                return;
            }
            XDocument doc = XDocument.Load(configPath);

            if (doc == null)
            {
                XlsxManager.Log(false, $"配置文件加载失败!{configPath}");
                return;
            }
            foreach (XElement xElement in doc.Root.Elements())
            {
                string attributeName  = xElement.Name.LocalName;
                string attributeValue = xElement.Value;
                if (attributeName == "ImportXlsxRelativePath")
                {
                    ImportXlsxRelativePath = attributeValue;
                }
                else if (attributeName == "ProjectVersionTool")
                {
                    ProjectVersionTool = attributeValue;
                }
                else if (attributeName == "CodeConfigDataMap")
                {
                    CodeConfigDataMap.Clear();
                    foreach (var item in xElement.Elements())
                    {
                        CodeConfigData codeConfigData = new CodeConfigData();
                        codeConfigData.Load(item);
                        CodeConfigDataMap.Add(codeConfigData.CodeName, codeConfigData);
                    }
                }
            }
        }