| | 1 | | using Microsoft.Xrm.Sdk; |
| | 2 | | using System; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.Reflection; |
| | 5 | |
|
| | 6 | | namespace FakeXrmEasy.Extensions |
| | 7 | | { |
| | 8 | | public static class TypeExtensions |
| | 9 | | { |
| | 10 | | public static bool IsOptionSet(this Type t) |
| 6280 | 11 | | { |
| 6280 | 12 | | var nullableType = Nullable.GetUnderlyingType(t); |
| 6280 | 13 | | return t == typeof(OptionSetValue) |
| 6280 | 14 | | || t.IsEnum |
| 6280 | 15 | | || nullableType != null && nullableType.IsEnum; |
| 6280 | 16 | | } |
| | 17 | |
|
| | 18 | | #if FAKE_XRM_EASY_9 |
| | 19 | | public static bool IsOptionSetValueCollection(this Type t) |
| 178 | 20 | | { |
| 178 | 21 | | var nullableType = Nullable.GetUnderlyingType(t); |
| 178 | 22 | | return t == typeof(OptionSetValueCollection); |
| 178 | 23 | | } |
| | 24 | | #endif |
| | 25 | |
|
| | 26 | | public static bool IsDateTime(this Type t) |
| 1715 | 27 | | { |
| 1715 | 28 | | var nullableType = Nullable.GetUnderlyingType(t); |
| 1715 | 29 | | return t == typeof(DateTime) |
| 1715 | 30 | | || nullableType != null && nullableType == typeof(DateTime); |
| 1715 | 31 | | } |
| | 32 | |
|
| | 33 | | public static bool IsNullableEnum(this Type t) |
| 0 | 34 | | { |
| 0 | 35 | | return |
| 0 | 36 | | t.IsGenericType |
| 0 | 37 | | && t.GetGenericTypeDefinition() == typeof(Nullable<>) |
| 0 | 38 | | && t.GetGenericArguments()[0].IsEnum; |
| 0 | 39 | | } |
| | 40 | | } |
| | 41 | | } |