⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commands.cs

📁 微软的行业应用解决方案示例
💻 CS
字号:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.Mobile.Data
{
    /// <summary>
    /// 
    /// </summary>
    internal class Commands : Dictionary<string, CommandItem>
    {
        /// <summary>
        /// 
        /// </summary>
        public int MaxItems
        {
            get;
            set;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="command"></param>
        public new void Add(string key, CommandItem command)
        {
            int minItemUse = int.MaxValue;
            string removeKey = string.Empty;

            // Enforce not adding more than the maximum items
            if (this.Count >= MaxItems)
            {
                // remove an item first
                foreach (KeyValuePair<string, CommandItem> currentItem in this)
                {
                    if (currentItem.Value.Count < minItemUse)
                    {
                        minItemUse = currentItem.Value.Count;
                        removeKey = currentItem.Key;
                    }
                }
                if (!string.IsNullOrEmpty(removeKey))
                {
                    this[removeKey].Command.Dispose();
                    this.Remove(removeKey);
                }
            }
            base.Add(key, command);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -