当前位置: 首页 > wzjs >正文

订餐网站的数据库建设软文100字左右案例

订餐网站的数据库建设,软文100字左右案例,美食网站建设合同范例,临沂阿里巴巴网站建设配置文件的读取 在AutoCAD插件开发中,可能需要生成、修改、读取配置文件中一些参数或设置。JSON格式的配置文件易于编写和修改,且可以方便地反序列化为对象进行使用。 运行后效果如下 using Autodesk.AutoCAD.ApplicationServices; using Autodesk.Au…

配置文件的读取

在AutoCAD插件开发中,可能需要生成、修改、读取配置文件中一些参数或设置。JSON格式的配置文件易于编写和修改,且可以方便地反序列化为对象进行使用。

运行后效果如下

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Newtonsoft.Json;
using System;
using System.IO;
using Path = System.IO.Path;
// AutoCAD 命令示例
public class ConfigCommands
{[CommandMethod("xx")]public void 加载文件配置(){Document doc = Application.DocumentManager.MdiActiveDocument;Editor ed = doc.Editor;// 加载配置AppConfig config = ConfigManager.LoadConfig();// 应用配置到图纸ConfigManager.ApplyConfigToDrawing(config);ed.WriteMessage($"\n已加载配置:默认图层 {config.DefaultLayer}");}[CommandMethod("tt")]public void 修改文件配置(){Document doc = Application.DocumentManager.MdiActiveDocument;Editor ed = doc.Editor;// 获取当前配置AppConfig config = ConfigManager.LoadConfig();// 修改配置示例config.DefaultLayer = "MyNewLayer";config.DefaultLineWeight = 0.5;// 保存配置ConfigManager.SaveConfig(config);ed.WriteMessage("\n配置已更新并保存");}
}
// 配置文件数据结构(示例)
public class AppConfig
{public string DefaultLayer { get; set; } = "0";      // 默认图层public double DefaultLineWeight { get; set; } = 0.3; // 默认线宽(毫米)public string[] RecentFiles { get; set; }            // 最近打开文件记录public ColorSetting Colors { get; set; }             // 颜色配置
}public class ColorSetting
{public int Background { get; set; } = 16777215;     // 背景色(RGB白色)public int SelectionHighlight { get; set; } = 255;   // 选择高亮色(红色)
}public static class ConfigManager
{private static readonly string ConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"MyAutoCADPlugin","config.json");/// <summary>/// 加载配置文件/// </summary>public static AppConfig LoadConfig(){try{// 如果配置文件不存在,创建默认配置if (!File.Exists(ConfigPath)){var defaultConfig = new AppConfig();SaveConfig(defaultConfig);return defaultConfig;}// 读取并反序列化JSONstring json = File.ReadAllText(ConfigPath);return JsonConvert.DeserializeObject<AppConfig>(json);}catch (Exception ex){Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\n配置加载失败: {ex.Message}");return new AppConfig(); // 返回空配置}}/// <summary>/// 保存配置文件/// </summary>public static void SaveConfig(AppConfig config){try{// 确保目录存在Directory.CreateDirectory(Path.GetDirectoryName(ConfigPath));// 序列化并保存string json = JsonConvert.SerializeObject(config, Formatting.Indented);File.WriteAllText(ConfigPath, json);}catch (Exception ex){Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\n配置保存失败: {ex.Message}");}}/// <summary>/// 应用配置到当前图纸/// </summary>public static void ApplyConfigToDrawing(AppConfig config){Database db = HostApplicationServices.WorkingDatabase;using (Transaction tr = db.TransactionManager.StartTransaction()){try{// 获取层表LayerTable lt = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;// 检查默认图层是否存在if (!lt.Has(config.DefaultLayer)){// 创建新图层LayerTableRecord ltr = new LayerTableRecord{Name = config.DefaultLayer,LineWeight = LineWeight.LineWeight030};lt.UpgradeOpen();lt.Add(ltr);tr.AddNewlyCreatedDBObject(ltr, true);}// 设置当前图层db.Clayer = lt[config.DefaultLayer];tr.Commit();}catch (Exception ex){tr.Abort();Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage($"\n配置应用失败: {ex.Message}");}}}
}

http://www.dtcms.com/wzjs/518395.html

相关文章:

  • 相城建设监理有限公司网站排名优化培训
  • 旅游网站设计模板图片西安网站优化
  • 做网站续费搜索引擎优化的主要策略
  • 青岛网上房地产查询系统网站关键词优化报价
  • 青浦网站制作su35google网页版登录入口
  • ps做产品的网站网络媒体发稿平台
  • 资源采集网站如何做站长基地
  • 长沙小升初有什么做试卷的网站优量汇广告平台
  • 阜宁建设网站的公司seo站长工具平台
  • 重庆政府网站建设单位做网络推广的团队
  • magento跨境b2b网站建设电商运营数据六大指标
  • 怎么做公司网站优化360关键词指数查询
  • 企业网站需要注意什么一般开车用什么导航最好
  • 山西省城乡住房和建设厅网站建立网站平台
  • 信息网站怎么做网络媒体推广方案
  • 国内大的网站建设公司商铺营销推广方案
  • 加强党建网站建设的重要性北京做网站的公司有哪些
  • 网站显示内容不显示不出来百度app安装下载
  • 最好用的网站开发软件最近三天的新闻热点
  • 漳州网站建设到博大赞成都搜狗seo
  • 五八同城客服网站怎么做人力资源培训机构
  • 全球知名购物网站有哪些南京百度推广优化
  • 深圳发型网站建设电商seo名词解释
  • 做网站的规范尺寸专业竞价托管
  • WordPress网站远程访问南阳网站seo
  • 电子商城网站建设费用百度网站排名规则
  • 网盘做网站空间百度收录在线提交
  • 福州培训网站建设天琥设计培训学校官网
  • 创新的沈阳网站建设搜索引擎网络推广方法
  • 绵阳房产网站建设公司官网模板