上一页 1 2 3 4 5 6 7 8 9 10 ··· 16 下一页
摘要: 用途:节约空间,共享单元 示例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) 编辑
摘要: Decorator in Dependency Injection public interface IReportServer { void PrintReport(); } public class ReportService : IReportServer { public void Prin 阅读全文
posted @ 2022-05-19 16:44 后跳 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 静态装饰组合Static Decorator Compsition public abstract class Shape { public abstract string AsString(); } public class Circel : Shape { float ridus; public 阅读全文
posted @ 2022-05-19 16:15 后跳 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 装饰者模式 检查装饰器循环 过度设计 较复杂。 public abstract class Shape { public virtual string AsString() => string.Empty; } class Circel : Shape { float ridus; public C 阅读全文
posted @ 2022-05-19 15:18 后跳 阅读(23) 评论(0) 推荐(0) 编辑
摘要: DesignPartten_Decoration_Dynamic_Composition 先定义个一个形状的接口,可以转换为字符串 interface IShape { string AsString(); } 添加各种形状 class Circel:IShape { float ridus; pu 阅读全文
posted @ 2022-05-18 15:19 后跳 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 装饰器模式 Multiple Inheritance多重继承 鸟 会飞 蜥蜴 会爬行 龙 能飞也能爬行 C# 不支持多继承,单可以多实现、所以我们这样做 public interface IBrid { void Fly(); } public class Brid: IBrid { public 阅读全文
posted @ 2022-05-17 16:16 后跳 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 装饰者模式: 例子:对StringBuilder进行装饰 public class MyString { private StringBuilder sb = new StringBuilder(); public static implicit operator MyString(string s 阅读全文
posted @ 2022-05-17 13:57 后跳 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 例子:对应 https://www.cnblogs.com/Zingu/p/16256988.html enum Color { Yellow, Red, Green } enum Size { Small, Medium, Large, Yuge } class Product { public 阅读全文
posted @ 2022-05-14 17:29 后跳 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 复合模式 神经元和神经元组 public static class ExtensitionNeural { //public static void ShowNeuralsIn(this Neural l, int dent) //{ // Console.WriteLine($"{new stri 阅读全文
posted @ 2022-05-14 16:06 后跳 阅读(58) 评论(0) 推荐(0) 编辑
摘要: class GraphicObject { public virtual string GroupName { get; set; }= "Group"; public string Color; private Lazy<List<GraphicObject>> graphicObjects = 阅读全文
posted @ 2022-05-14 13:08 后跳 阅读(55) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 16 下一页