private void Form1_Load(object sender, EventArgs e) { // 获取本地路径 it.LocalPath = Application.StartupPath; if (!it.LocalPath.EndsWith("\\")) { it.LocalPath += "\\"; } //// 获取系统配置 //string configPath = $"{it.LocalPath}ModularProject.cfg"; //string templateName = null; //using (dpz3.File.ConfFile conf = new dpz3.File.ConfFile(it.LocalPath)) { // // 处理和模板相关的配置 // var group = conf["template"]; // if (!group.ContainsKey("name")) { // group["name"] = "default"; // conf.Save(); // } // templateName = group["name"]; //} //// 模板目录 //it.LocalTemplateFolder = $"{it.LocalPath}{it.Path_TemplateFolder}\\{templateName}"; //if (!System.IO.Directory.Exists(it.LocalTemplateFolder)) System.IO.Directory.CreateDirectory(it.LocalTemplateFolder); // 设置标题 this.Text = $"{Application.ProductName} Ver:{Application.ProductVersion}"; // 工具栏初始化 this.toolStripMenuItemBuildAdd.Enabled = false; this.toolStripMenuItemBuildEdit.Enabled = false; this.toolStripMenuItemBuildTable.Enabled = false; this.toolStripMenuItemBuildSelector.Enabled = false; this.toolStripMenuItemBuildView.Enabled = false; this.toolStripMenuItemBuildClass.Enabled = false; this.toolStripButtonBuildAdd.Enabled = false; this.toolStripButtonBuildEdit.Enabled = false; this.toolStripButtonBuildTable.Enabled = false; this.toolStripButtonBuildSelector.Enabled = false; this.toolStripButtonBuildView.Enabled = false; this.toolStripButtonBuildClass.Enabled = false; // 初始化变量 _pages = new KeyValues <string>(); this.Visible = true; Application.DoEvents(); if (!it.WorkPathInit.IsNoneOrNull()) { this.SetWorkPath(it.WorkPathInit); } }
public ModularMiddleware(RequestDelegate next) { _next = next; _packages = new List <ModularPackage>(); _mimes = new KeyValues <string>(); // 加载mime集合 LoadMimes(); // 安装包文件 InstallPacks(); //string path = $"{it.ExecPath}lib{it.SplitChar}ClassDemo.dll"; //RegLibrary(path); }
public ModularPackage(dpz3.KeyValues <string> mimes, string folderPackage, string packageName, string packageVersion) { // 初始化接口列表信息 Posts = new List <ModularMethodInfo>(); Gets = new List <ModularMethodInfo>(); _mimes = mimes; // 读取包信息 this.Name = packageName; this.Version = packageVersion; string folderInstall = $"{folderPackage}{it.SplitChar}{packageName}{it.SplitChar}{packageVersion}"; this.WorkPath = folderInstall; this.RootPath = $"{folderInstall}{it.SplitChar}wwwroot"; Program.Println($"[*] 读取包版本 {packageName} 安装版本:{packageVersion}"); // 判断依赖有效性 string pathCfg = $"{folderInstall}{it.SplitChar}modular.json"; Program.Println($" 读取包配置文件 {pathCfg} ..."); bool isEnable = false; int plmVersion = 0; if (System.IO.File.Exists(pathCfg)) { string szJson = dpz3.File.UTF8File.ReadAllText(pathCfg); using (var json = dpz3.Json.Parser.ParseJson(szJson)) { string jsonName = json.Str["name"]; string jsonVersion = json.Str["version"]; string jsonDescription = json.Str["description"]; var jsonDepends = json.Arr["depend"]; // Program.Println($" 获取包 {packageName} 信息"); Program.Println($" 名称:{jsonName}"); Program.Println($" 版本:{jsonVersion}"); Program.Println($" 描述:{jsonDescription}"); for (int i = 0; i < jsonDepends.Count; i++) { var depend = jsonDepends.Obj[i]; string dependPlatform = depend.Str["platform"]; int dependVersion = depend.Int["version"]; Program.Println($" 依赖 => {dependPlatform}:{dependVersion}"); if (dependPlatform == Platform_Name) { plmVersion = dependVersion; } } } } if (plmVersion < Platform_Version) { Program.Println($"[-] 包 {packageName} 依赖关系不符合: 此包适用于旧版本主程序,请更新包或联系开发者进行更新"); } else if (plmVersion < Platform_Version) { Program.Println($"[-] 包 {packageName} 依赖关系不符合: 此包适用于更新版本的主程序,请升级主程序"); } else { isEnable = true; } if (isEnable) { // 注册控制器 string pathDll = $"{folderInstall}{it.SplitChar}controller.dll"; if (System.IO.File.Exists(pathDll)) { Program.Println($" 包 {packageName} 控制器激活中 ..."); RegLibrary(pathDll); } } }