public bool IsTypeSerializable(Type type)
{
return _isTypeSerializableCache.GetFromCacheOrFetch(type, () =>
{
if (type.IsAbstractEx())
{
return false;
}
if (type.IsInterfaceEx())
{
return false;
}
if (type.IsEnumEx())
{
return true;
}
if (IsSpecialCollectionType(type))
{
return true;
}
// Should have an empty constructor
if (type.GetConstructorEx(new Type[0]) == null)
{
return false;
}
// Type must be public
if (!type.IsPublicEx() && !type.IsNestedPublicEx())
{
return false;
}
// TODO: Add more checks?
return true;
});
}