12 2020 档案

摘要:C# Task Delay 使用 方法一: public static System.Threading.Tasks.Task Delay (int millisecondsDelay, System.Threading.CancellationToken cancellationToken); 创 阅读全文
posted @ 2020-12-28 16:14 NiKaFace 阅读(3359) 评论(0) 推荐(0)
摘要:1. 使用控件的Invoke或者BeginInvoke: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, E 阅读全文
posted @ 2020-12-28 11:44 NiKaFace 阅读(391) 评论(0) 推荐(0)
摘要:命名空间: System.Windows.Forms 程序集: System.Windows.Forms.dll MethodInvoker 表示一个委托,该委托可执行托管代码中声明为 void 且不接受任何参数的任何方法。 public delegate void MethodInvoker(); 阅读全文
posted @ 2020-12-28 11:25 NiKaFace 阅读(382) 评论(0) 推荐(0)
摘要:Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activate 'xxxx'. 构造注入时需要加入类名 public class DeviceStateCom 阅读全文
posted @ 2020-12-23 17:03 NiKaFace 阅读(861) 评论(0) 推荐(0)
摘要:从 C# 7.0 开始,C# 支持弃元,这是一种在应用程序代码中人为取消使用的占位符变量。 弃元相当于未赋值的变量;它们没有值。 因为只有一个弃元变量,甚至不为该变量分配存储空间,所以弃元可减少内存分配。 因为它们使代码的意图清楚,增强了其可读性和可维护性。 通过将下划线 (_) 赋给一个变量作为其 阅读全文
posted @ 2020-12-23 10:38 NiKaFace 阅读(1788) 评论(1) 推荐(1)
摘要:【译】Serilog 配置基础知识 Serilog 使用简单的C# API来配置日志记录。当外部配置需要时,可以使用Serilog.Settings.AppSettings包(.NET 框架)或Serilog.Settings.Configuration(.NET Core) 谨慎混合。 本文目录: 阅读全文
posted @ 2020-12-22 20:02 NiKaFace 阅读(3830) 评论(0) 推荐(1)
摘要:测试设备必须要遵守的一些准则--TTStand版本,罗列如下: 注释1 :TestStand​ 代码​模​块​开发​最佳​实践【1】 注释2 :NI LabVIEW 编程规范 阅读全文
posted @ 2020-12-17 15:10 NiKaFace 阅读(704) 评论(0) 推荐(0)
摘要:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Extensions.Configu 阅读全文
posted @ 2020-12-12 23:38 NiKaFace 阅读(469) 评论(0) 推荐(0)
摘要:访问者模式 1.倾斜可扩展性设计 2.消息处理 代码实现: 实体类: namespace VisitorPattern { public abstract class BaseAdult { public string Name { get; set; } public abstract void 阅读全文
posted @ 2020-12-08 20:33 NiKaFace 阅读(189) 评论(0) 推荐(0)
摘要:策略模式 代码实现: 计算服务类: namespace StrategyPattern.Service { public interface ICalculation { public int Calculate(int data1,int data2); } public class Plus:I 阅读全文
posted @ 2020-12-08 16:15 NiKaFace 阅读(182) 评论(0) 推荐(0)
摘要:状态模式 代码实现: 交通类: namespace StatePattern { public abstract class BaseLight { private LightColor _lightColor; public abstract void Show(); public abstrac 阅读全文
posted @ 2020-12-08 14:45 NiKaFace 阅读(199) 评论(0) 推荐(0)
摘要:观察者模式 代码实现: 事件类: namespace ObserverPattern.Subject { public class Cat { private readonly List<IObserver> _observerList = new List<IObserver>(); public 阅读全文
posted @ 2020-12-08 11:28 NiKaFace 阅读(233) 评论(0) 推荐(0)
摘要:备忘模式 代码实现: 实体类: public class War3 { public string Race { get; set; } public string Hero { get; set; } public string Army { get; set; } public string R 阅读全文
posted @ 2020-12-07 23:11 NiKaFace 阅读(106) 评论(0) 推荐(0)
摘要:中介者模式 1.解决对象交互问题 代码实现: 部门员工类: namespace MediatorPattern { public abstract class BasePerson { public string Name { get; set; } public abstract void Sen 阅读全文
posted @ 2020-12-07 18:12 NiKaFace 阅读(259) 评论(0) 推荐(0)
摘要:迭代器模式 1. Yield Return 2. 提供统一的访问方式 代码实现: 食品类: public class Food { public int Id { get; set; } public string Name { get; set; } public int Price { get; 阅读全文
posted @ 2020-12-07 16:08 NiKaFace 阅读(136) 评论(0) 推荐(0)
摘要:命令模式 1. 实现异步队列 2.数据恢复,命令撤销 代码实现: 对象: namespace CommandPattern { public class Document { public int Id { get; set; } public string Name { get; set; } } 阅读全文
posted @ 2020-12-07 13:36 NiKaFace 阅读(144) 评论(0) 推荐(0)
摘要:责任链模式 1.逻辑封装和转移 代码实现: 上下文: public class ApplyContext { public int Id { get; set; } public string Name { get; set; } public int Hour { get; set; } publ 阅读全文
posted @ 2020-12-07 02:06 NiKaFace 阅读(181) 评论(0) 推荐(0)
摘要:模板方法 1.定义通用处理流程,实现通用部分,可变部分留作扩展 代码实现: 模板: namespace TempleteMethodPattern { public abstract class BaseClient { public decimal Deposit { get; set; } pu 阅读全文
posted @ 2020-12-06 20:53 NiKaFace 阅读(198) 评论(0) 推荐(0)
摘要:代理模式 1. 基于开闭原则 OCP: 对扩展开放,对修改封闭。 购物类: namespace ProxyPattern { public interface IShopping { void ChoiceProduct(string product); void PayForProduct(); 阅读全文
posted @ 2020-12-04 14:58 NiKaFace 阅读(138) 评论(0) 推荐(0)
摘要:享元模式 1.解决对象复用问题 2.不破坏原本类的封装 3.池化资源管理:避免对象重复创建和销毁(尤其是非托管资源) 4.字符串 内存分配使用是享元模式(排除部分分配) 代码实现: namespace FlyWeightPattern { public interface ILetter { pub 阅读全文
posted @ 2020-12-03 17:45 NiKaFace 阅读(223) 评论(0) 推荐(0)
摘要:外观模式 1. 分层、封装 减少上层复杂度 代码实现: 商品下单走物流: namespace FacadePattern.User { public interface IUser { public bool CheckUser(int userId); } public class User:IU 阅读全文
posted @ 2020-12-03 13:55 NiKaFace 阅读(170) 评论(0) 推荐(0)
摘要:装饰器模式 1.继承+组合 2. AOP编程思想的一种实现 代码实现: 员工: namespace DecoratorPattern { public abstract class AbstractEmployee { public int Id { get; set; } public strin 阅读全文
posted @ 2020-12-03 10:16 NiKaFace 阅读(407) 评论(0) 推荐(0)
摘要:组合模式 1. 运用递归 2. 组合模式:分透明和安全 代码实现: 项目提成 namespace CompositePattern { public abstract class AbstractDomain { public string Name { get; set; } public int 阅读全文
posted @ 2020-12-02 14:35 NiKaFace 阅读(191) 评论(0) 推荐(0)
摘要:桥接模式 1.解决多维度问题 2.变化封装 代码实现: 组合 变化封装类 减少子类的数量 手机系统桥接 namespace BridgePattern.Bridge { public interface ISystem { public string GetSystem(); public stri 阅读全文
posted @ 2020-12-02 11:46 NiKaFace 阅读(119) 评论(0) 推荐(0)
摘要:适配器模式 1. 类适配器 (通过继承) 2. 对象适配器 (通过组合) 组合优于继承 数据库适配,代码实现: 原始类 Sql server /MySql namespace AdapterPattern { interface IHelper { void Add<T>(); void Delet 阅读全文
posted @ 2020-12-01 17:54 NiKaFace 阅读(152) 评论(0) 推荐(0)
摘要:原型模式 1.利用对象拷贝,快速获取对象 学生原型: public class StudentPrototype { public int Id { get; set; } public string Name { get; set; } public Class Class { get; set; 阅读全文
posted @ 2020-12-01 16:20 NiKaFace 阅读(148) 评论(0) 推荐(0)
摘要:建造者模式 1. 复杂对象创建,包含多步骤 2. 建造流程相对固定 代码实现:造车 模型: namespace BuilderPattern.Models { public class Engine { public string Name { get; set; } } public class 阅读全文
posted @ 2020-12-01 13:44 NiKaFace 阅读(286) 评论(0) 推荐(0)
摘要:抽象工厂模式 1. 倾斜的可扩展性设计:产品簇扩展方便,工厂职责不能扩展 代码实现: 三国服务: namespace AbstractFactory.SanGuoService { public interface ILord { void ShowLord(); } public class Lo 阅读全文
posted @ 2020-12-01 10:49 NiKaFace 阅读(175) 评论(0) 推荐(0)
摘要:C# 设计模式(1)单例模式 C# 设计模式(2)简单工厂模式 C# 设计模式(3)工厂方法模式 C# 设计模式(4)抽象工厂模式 C# 设计模式(5)建造者模式 C# 设计模式(6)原型模式 C# 设计模式(7)适配器模式 C# 设计模式(8)桥接模式 C# 设计模式(9)组合模式 C# 设计模式 阅读全文
posted @ 2020-12-01 08:41 NiKaFace 阅读(335) 评论(0) 推荐(1)
摘要:1. 基于开闭原则 OCP: 对扩展开放,对修改封闭。 2. 基于单一原则 代码实现:WarCraft3 服务 namespace FactoryMethod.Warcraft3Service { public interface IRace { void InterWar(); } public 阅读全文
posted @ 2020-12-01 01:27 NiKaFace 阅读(165) 评论(0) 推荐(0)