测试 属性 是否是便携式 class 库中的 ICollection

Test if a property is an ICollection in Portable class library

我正在尝试测试我的对象的 属性 是否是一个集合,但遇到问题,因为在可移植 class 库中许多方法不可用

这是我的方法:

public virtual bool Equals(TObject other) // where TObject : class
{
    if (other == null)
        return false;

    Type t = GetType();
    Type otherType = other.GetType();

    TypeInfo typeInfo = t.GetTypeInfo();            

    if (t != otherType)
        return false;

    IEnumerable<FieldInfo> fields = typeInfo.DeclaredFields; 
    foreach (FieldInfo field in fields)
    { ...

现在我必须测试字段是否是 Icollection 但是

也许这是因为我有 FieldInfo 而不是 TypeInfo?

有什么我可以做的吗?

我通过 linq Linq

解决了排除这种类型的问题
IEnumerable<FieldInfo> fields = typeInfo.DeclaredFields.Where(x => x.FieldType.Name != typeof(ICollection<>).Name);