摘要: Dynamic Proxy 情景: 定义银行接口,包含两个方法 存钱和取钱 需要在原有接口基础上记录存钱和取钱的次数相关信息; Nuget:ImpromptuInterface 实现: public interface IBankAccount { void Deposit(int amount); 阅读全文
posted @ 2022-05-20 18:35 后跳 阅读(18) 评论(0) 推荐(0) 编辑
摘要: Compositite_Proxy_Array_Backed_Properties 情景: 有四个点选框 主项是All 子项是Pillars, Walls, Floors; 若子项全选中则主项选中,子项有一项未选中,则主项也未选中。 图例如下(红色为选中): 实现1: public class Ma 阅读全文
posted @ 2022-05-20 17:38 后跳 阅读(21) 评论(0) 推荐(0) 编辑
摘要: Compositite Proxy_SoA_AoS 情景1: 一个游戏 有100个对象的X坐标需要全部移动; class Creature { public byte Age; public int X, Y; } class Program { static void Main(string[] 阅读全文
posted @ 2022-05-20 16:28 后跳 阅读(6) 评论(0) 推荐(0) 编辑
摘要: Value Proxy [DebuggerDisplay("{value*100.0d}%")] public struct Perceentage { private readonly double value; public Perceentage(double value) { this.va 阅读全文
posted @ 2022-05-20 15:08 后跳 阅读(18) 评论(0) 推荐(0) 编辑
摘要: Property Proxy public class Property<T>:IEquatable<Property<T>> where T:new() { private T value; public T Value { get => value; set { if (this.value.E 阅读全文
posted @ 2022-05-20 14:08 后跳 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 行车不规范,情人两行泪! 代理模式: public interface ICar { void Driver(); } public class Car : ICar { public void Driver() { Console.WriteLine("Car is running"); } } 阅读全文
posted @ 2022-05-20 12:10 后跳 阅读(46) 评论(0) 推荐(0) 编辑
摘要: GoF 设计模式 享元例子: 示例1:将一段文字的某一段内容转换为大写: class TextFormatted { private string text; private bool[] isFormatted; public TextFormatted(string text) { this.t 阅读全文
posted @ 2022-05-20 11:38 后跳 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 用途:节约空间,共享单元 示例1:重复用户 public class User { string fullName; public User(string fullName) { this.fullName = fullName; } public override string ToString( 阅读全文
posted @ 2022-05-20 10:48 后跳 阅读(16) 评论(0) 推荐(0) 编辑