protocollist.cs

来自「Gibphone is CSharp Program, it can tell 」· CS 代码 · 共 27 行

CS
27
字号
using System;
using System.Collections.Generic;
using System.Text;
using GPCore.Protocols;

namespace GPCore
{
    /// <summary>
    /// A List of Protocols.
    /// </summary>
    public class ProtocolList : List<IProtocol>
    {
        /// <summary>
        /// Returns a SubList of all the Protocols in the list that extend interface T.
        /// </summary>
        /// <typeparam name="T">The sub-interface of IProtocol to look for.</typeparam>
        public IEnumerable<T> SubList<T>() where T : IProtocol
        {
            foreach (IProtocol p in this)
            {
                if (p.GetType() == typeof(T))
                    yield return (T) Convert.ChangeType(p,typeof(T));
            }
        }
    }
}

⌨️ 快捷键说明

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