| 12345678910111213141516171819 |
- using System.Collections.Generic;
- namespace TeamAAS.FlowEngine
- {
- /// <summary>
- /// 集合扩展方法。
- /// 背景:DeleteIfExistsKey 原先来自 HandyControls fork 的 HandyControl.Tools.Extension,
- /// 切换到官方 HandyControl 后由本文件补齐等价实现,避免依赖 fork 包。
- /// </summary>
- public static class DictionaryExtensions
- {
- /// <summary>存在则删除指定键,不存在则静默跳过</summary>
- public static bool DeleteIfExistsKey<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
- {
- if (dictionary == null || key == null) return false;
- return dictionary.Remove(key);
- }
- }
- }
|