iam trying to test if a property of my object is a collection or not but encounter problem since in portable class library many method are not avaible
this is my method:
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)
{ ...
now i have to test if field is an Icollection or not but
maybe this is because i have FieldInfo and not TypeInfo?
is there something i can do?
i solved it excludind this type via linq Linq
IEnumerable<FieldInfo> fields = typeInfo.DeclaredFields.Where(x => x.FieldType.Name != typeof(ICollection<>).Name);