forked from JSONAPIdotNET/JSONAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypeExtensions.cs
More file actions
22 lines (19 loc) · 803 Bytes
/
TypeExtensions.cs
File metadata and controls
22 lines (19 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
namespace JSONAPI.Extensions
{
internal static class TypeExtensions
{
internal static bool CanWriteAsJsonApiAttribute(this Type objectType)
{
if (objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof (Nullable<>))
objectType = objectType.GetGenericArguments()[0];
return objectType.IsPrimitive
|| typeof (Decimal).IsAssignableFrom(objectType)
|| typeof (Guid).IsAssignableFrom(objectType)
|| typeof (DateTime).IsAssignableFrom(objectType)
|| typeof (DateTimeOffset).IsAssignableFrom(objectType)
|| typeof (String).IsAssignableFrom(objectType)
|| objectType.IsEnum;
}
}
}