利用反射把查詢到的Table、Reader轉換成List、Model

来源:http://www.cnblogs.com/lifuquan/archive/2016/05/06/5466043.html
-Advertisement-
Play Games

菜鳥一枚,入園已有兩年三個月,這還是第一次寫博客,請各位大神斧正。 這是我寫的一個工具類,通常我們從資料庫查詢到一個 DataReader 或者是 一個 Table , 想要轉換成 一個 list 或者是 一個model 的話 , 一般情況下是使用foreach 迴圈reader或是table的ro ...


 

菜鳥一枚,入園已有兩年三個月,這還是第一次寫博客,請各位大神斧正。

 

這是我寫的一個工具類,通常我們從資料庫查詢到一個  DataReader  或者是  一個 Table , 想要轉換成 一個 list 或者是 一個model 的話 , 一般情況下是使用foreach 迴圈reader或是tablerows,然後在迴圈內創建個對象,通過reader[“列名”]來賦值對象的屬性。如果表的欄位少的話,用這種方式還可以,速度也快一點。但是如果後續還會增加欄位的話,那就非常麻煩了,要改很多地方。這工作量太大了,而且還很容易出錯。所以這個時候使用反射來轉換的話就非常便捷了。我們只管增加欄位,改一下數據表對應的model,調用這個工具類的方法,傳入相對應的參數就能得到想要的結果。

 

誒,文筆不好,直接上代碼吧。

  1 /// <summary>
  2         /// table轉list
  3         /// </summary>
  4         /// <typeparam name="T">list類型</typeparam>
  5         /// <param name="obj">model對象</param>
  6         /// <param name="table">數據源table</param>
  7         /// <returns>list</returns>
  8         public static List<T> FillListByDataTable<T>(T obj, DataTable table)
  9         {
 10 
 11             Type type = obj.GetType();
 12 
 13             List<T> list = new List<T>();
 14 
 15             PropertyInfo[] properties = type.GetProperties();//model對象的屬性集合
 16 
 17             DataColumnCollection dcc = table.Columns;//列集合
 18 
 19             foreach (DataRow row in table.Rows)
 20             {
 21                 //複製一個model對象(深拷貝)
 22                 MemoryStream stream = new MemoryStream();
 23                 BinaryFormatter formatter = new BinaryFormatter();
 24                 formatter.Serialize(stream, obj);
 25                 stream.Position = 0;
 26                 T newObj = (T)formatter.Deserialize(stream);
 27 
 28                 foreach (PropertyInfo p in properties)
 29                 {
 30                     Type t = p.PropertyType;
 31 
 32                     if (dcc.Contains(p.Name.ToString()))
 33                     {
 34                         if (!string.IsNullOrEmpty(row[p.Name].ToString()))
 35                         {
 36                             //判斷欄位類型
 37                             if (t.Name != "Nullable`1")
 38                             {
 39                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], t, null));
 40                             }
 41                             else if (t.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 42                             {
 43                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(DateTime), null));
 44                             }
 45                             else if (t.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 46                             {
 47                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(DateTime), null));
 48                             }
 49                             else if (t.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 50                             {
 51                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Int32), null));
 52                             }
 53                             else if (t.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 54                             {
 55                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Int32), null));
 56                             }
 57                             else if (t.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 58                             {
 59                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Int64), null));
 60                             }
 61                             else if (t.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 62                             {
 63                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Int64), null));
 64                             }
 65                             else if (t.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 66                             {
 67                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Decimal), null));
 68                             }
 69                             else if (t.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 70                             {
 71                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Decimal), null));
 72                             }
 73                             else if (t.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 74                             {
 75                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Boolean), null));
 76                             }
 77                             else if (t.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
 78                             {
 79                                 p.SetValue(newObj, Convert.ChangeType(row[p.Name], typeof(Boolean), null));
 80                             }
 81                         }
 82 
 83                     }
 84                 }
 85                 list.Add(newObj);
 86             }
 87             return list;
 88         }
 89 
 90         /// <summary>
 91         /// reader轉list
 92         /// </summary>
 93         /// <typeparam name="T">list類型</typeparam>
 94         /// <param name="obj">model對象</param>
 95         /// <param name="reader">數據源reader</param>
 96         /// <returns>list </returns>
 97         public static List<T> FillListByDataReader<T>(T obj ,IDataReader reader)
 98         {
 99             List<T> list = new List<T>();
100 
101             Type t = obj.GetType();
102 
103             PropertyInfo[] proList = t.GetProperties();
104 
105             while(reader.Read())
106             {
107                 MemoryStream stream = new MemoryStream();
108                 BinaryFormatter formatter = new BinaryFormatter();
109                 formatter.Serialize(stream, obj);
110                 stream.Position = 0;
111                 T newObj = (T)formatter.Deserialize(stream);
112 
113                 foreach (PropertyInfo pro in proList)
114                 {
115                     Type tp = pro.PropertyType;
116 
117                     DataFieldAttribute attr = pro.GetCustomAttributes().Count() > 0 ? pro.GetCustomAttributes().First() as DataFieldAttribute : null;
118 
119                     if (attr != null && attr.ColumnName == pro.Name)
120                     {
121                         if (ReaderExists(reader, pro.Name) && !string.IsNullOrEmpty(reader[pro.Name].ToString()))
122                         {
123 
124                             if (tp.Name != "Nullable`1")
125                             {
126                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], tp));
127                             }
128                             else if (tp.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
129                             {
130                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(DateTime), null));
131                             }
132                             else if (tp.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
133                             {
134                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(DateTime), null));
135                             }
136                             else if (tp.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
137                             {
138                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Int32), null));
139                             }
140                             else if (tp.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
141                             {
142                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Int32), null));
143                             }
144                             else if (tp.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
145                             {
146                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Int64), null));
147                             }
148                             else if (tp.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
149                             {
150                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Int64), null));
151                             }
152                             else if (tp.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
153                             {
154                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Decimal), null));
155                             }
156                             else if (tp.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
157                             {
158                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Decimal), null));
159                             }
160                             else if (tp.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
161                             {
162                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Boolean), null));
163                             }
164                             else if (tp.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
165                             {
166                                 pro.SetValue(newObj, Convert.ChangeType(reader[pro.Name], typeof(Boolean), null));
167                             }
168                         }
169                     }
170                 }
171                 list.Add(newObj);
172             }
173 
174             return list;
175         }
176 
177         /// <summary>
178         /// reader轉model對象
179         /// </summary>
180         /// <typeparam name="T">類型</typeparam>
181         /// <param name="obj">model對象</param>
182         /// <param name="reader">數據源reader</param>
183         /// <returns>model對象</returns>
184         public static T FillObjectByDataReader<T>(T obj, IDataReader reader)
185         {
186             Type t = obj.GetType();
187 
188             PropertyInfo[] proList = t.GetProperties();
189 
190             if (reader.Read())
191             {
192                 foreach (PropertyInfo pro in proList)
193                 {
194                     Type tp = pro.PropertyType;
195 
196                     DataFieldAttribute attr = pro.GetCustomAttributes().Count() > 0 ? pro.GetCustomAttributes().First() as DataFieldAttribute : null;
197 
198                     if (attr != null && attr.ColumnName == pro.Name)
199                     {
200                         if (ReaderExists(reader, pro.Name) && !string.IsNullOrEmpty(reader[pro.Name].ToString()))
201                         {
202                             if (tp.Name != "Nullable`1")
203                             {
204                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], tp));
205                             }
206                             else if (tp.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
207                             {
208                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(DateTime), null));
209                             }
210                             else if (tp.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
211                             {
212                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(DateTime), null));
213                             }
214                             else if (tp.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
215                             {
216                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Int32), null));
217                             }
218                             else if (tp.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
219                             {
220                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Int32), null));
221                             }
222                             else if (tp.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
223                             {
224                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Int64), null));
225                             }
226                             else if (tp.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
227                             {
228                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Int64), null));
229                             }
230                             else if (tp.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
231                             {
232                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Decimal), null));
233                             }
234                             else if (tp.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
235                             {
236                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Decimal), null));
237                             }
238                             else if (tp.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
239                             {
240                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Boolean), null));
241                             }
242                             else if (tp.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
243                             {
244                                 pro.SetValue(obj, Convert.ChangeType(reader[pro.Name], typeof(Boolean), null));
245                             }
246                         }
247                     }
248                 }
249             }
250 
251             return obj;
252         }
253 
254         /// <summary>
255         /// row轉model對象
256         /// </summary>
257         /// <typeparam name="T">model類型</typeparam>
258         /// <param name="obj">model對象</param>
259         /// <param name="row">數據源row</param>
260         /// <returns>model對象</returns>
261         public static T FillObjectByDataTable<T>(T obj, DataRow row)
262         {
263             Type t = obj.GetType();
264 
265             PropertyInfo[] proList = t.GetProperties();
266 
267             foreach (PropertyInfo pro in proList)
268             {
269                 Type tp = pro.PropertyType;
270 
271                 DataFieldAttribute attr = pro.GetCustomAttributes().Count() > 0 ? pro.GetCustomAttributes().First() as DataFieldAttribute : null;
272 
273                 if (attr != null && attr.ColumnName == pro.Name)
274                 {
275                     if (!string.IsNullOrEmpty(row[pro.Name].ToString()))
276                     {
277                         if (tp.Name != "Nullable`1")
278                         {
279                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], tp, null));
280                         }
281                         else if (tp.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
282                         {
283                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(DateTime), null));
284                         }
285                         else if (tp.FullName == "System.Nullable`1[[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
286                         {
287                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(DateTime), null));
288                         }
289                         else if (tp.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
290                         {
291                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Int32), null));
292                         }
293                         else if (tp.FullName == "System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
294                         {
295                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Int32), null));
296                         }
297                         else if (tp.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
298                         {
299                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Int64), null));
300                         }
301                         else if (tp.FullName == "System.Nullable`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
302                         {
303                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Int64), null));
304                         }
305                         else if (tp.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
306                         {
307                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Decimal), null));
308                         }
309                         else if (tp.FullName == "System.Nullable`1[[System.Decimal, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
310                         {
311                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Decimal), null));
312                         }
313                         else if (tp.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
314                         {
315                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Boolean), null));
316                         }
317                         else if (tp.FullName == "System.Nullable`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]")
318                         {
319                             pro.SetValue(obj, Convert.ChangeType(row[pro.Name], typeof(Boolean), null));
320                         }
321                     }
322 
323                 }
324             }
325 
326 
327             return obj;
328         }
329 
330         /// <summary>
331         /// list轉table
332         /// </summary>
333         /// <typeparam name="T">list類型</typeparam>
334         /// <param name="list">數據源list</param>
335         /// <param name="table">table</param>
336         /// <returns>table</returns>
337         public static DataTable FillDataTableByObject<T>(List<T> list , DataTable table)
338         {
339             if (list.Count > 0)
340             {
341                 Type type = list[0].GetType();
342 
343                 PropertyInfo[] properties = type.GetProperties();
344 
345                 DataColumnCollection dcc = table.Columns;
346 
347                 foreach (var obj in list)
348                 {
349                     DataRow row = table.NewRow();
350                     foreach (PropertyInfo p in properties)
351                     {
352                         if (dcc.Contains(p.Name.ToString()))
353                         {
354                             row[p.Name] = p.GetValue(obj);
355        

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 好書不能只讀一遍,這兩天又翻看了一遍《你必須知道的.NET》,重溫了下基礎,重溫了下經典,簡單記錄了下來。 記憶體分配:CLR 管理記憶體的區域,主要有三塊,分別為: 線程的堆棧,用於分配值類型實例。堆棧主要由操作系統管理,而不受垃圾收集器的控制,當值類型實例所在方法結束時,其存儲單位自動釋放。棧的執行 ...
  • 剛開始接觸.NET很疑惑,看完視頻也不是太懂,通過總結和反覆,從概括和概念入手,慢慢變得清晰了。這篇博客主要是我對.NET基礎知識的瞭解,算作積累吧。 .NET框架體繫結構 由四個主要部分組成 公共語言運行時(CLR)是.NET框架應用程式的執行引擎..NET框架的關鍵作用在於,它提供了一個跨編程語 ...
  • 詳細步驟 創建文件夾,規劃好項目目錄 創建相關實體類 (Data Model) 創建 Database Context 創建Initializer, 使用EF初始化資料庫,插入測試數據 實現資料庫登錄驗證 總結 一,創建文件夾,規劃好項目目錄 1.根目錄下新建一個 ViewModels文件夾: Mo ...
  • Updated 22/Apr/2016: The NuGet package is now being uploaded daily. The payload doesn’t change every day but you should see new bug fixes and/or featu ...
  • 標題“Mvc擴展框架及DI”有點繞口,我也想不出好的命名,因為這個內容很雜,涉及多個模塊,但在日常開發又密不可分 首先說Mvc擴展框架,該Mvc擴展就是把以前的那個Mvc分區擴展框架遷移過來,並優化整合了一下 一、Mvc擴展框架主要功能: 1、Mvc的依賴註入(DI)功能(類MvcDependenc ...
  • UWP 是Universal Windows Platform,即Windows通用應用平臺。UWP平臺提供了一次重新洗牌的機會,你還會等待嗎? ...
  • 回到目錄 C#里的值類型你是否真的瞭解,是否真的清楚了,下麵大叔總結了一下,自己在這個時候正好也回味了一下,確實有些類型自己都忘記了! 上學時的基礎知識 一個位元組=8位 1byte=8bit 整型 8位:byte,值(0~255),占1個位元組 8位帶符號:sbyte,值(-128~127),占1個字 ...
  • AES 高級加密標準(英語:Advanced Encryption Standard,縮寫:AES),在密碼學中又稱Rijndael加密法,是美國聯邦政府採用的一種區塊加密標準。這個標準用來替代原先的DES,已經被多方分析且廣為全世界所使用。AES先進加密演算法是一向被認為牢不可破的加密演算法,針對這項 ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...