C#定義一個Call API並返回Stream的共用方法_參數支援傳入不同物件的彈性設計(依賴倒轉原則DIP)

在很久以前有寫過有關SOLID的文章 設計模式特訓_Day01_SOLID五項鐵則 https://coolmandiary.blogspot.com/2017/05/day01solid.html 如今在專案偕同過程也遇到實踐機會 假設我今天有一個method想要傳入固定要做 json反序列化成其對應物件的Model Class 這種Model Class可能在專案裡面有一或多個 IC_KeyWord_Model 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; /// <summary> /// IC_KeyWord_Model 的摘要描述 /// </summary> public class IC_KeyWord_Model { [JsonProperty(PropertyName = "keyword")] public string keyword { get ; set ; } [JsonProperty(PropertyName = "similar words")] public string [] similarwords { get ; set ; } [JsonProperty(PropertyName = "additional words")] public string [] additionalwords { get ; set ; } } IC_RcmdAssg_Model 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 using Newtonsoft.Json; using System...