Skip to content

Commit 35ad759

Browse files
committed
Tidy up type extensions
1 parent a9cd487 commit 35ad759

File tree

2 files changed

+23
-41
lines changed

2 files changed

+23
-41
lines changed

src/Nest/CommonAbstractions/Extensions/TypeExtensions.cs

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private static ObjectActivator<T> GetActivator<T>(ConstructorInfo ctor)
8585
Expression[] argsExp =
8686
new Expression[paramsInfo.Length];
8787

88-
//pick each arg from the params array
88+
//pick each arg from the params array
8989
//and create a typed expression of them
9090
for (int i = 0; i < paramsInfo.Length; i++)
9191
{
@@ -124,43 +124,5 @@ internal static IList<JsonProperty> GetCachedObjectProperties(this Type t, Membe
124124
_cachedTypeProperties.TryAdd(t, propertyDictionary);
125125
return propertyDictionary;
126126
}
127-
128-
#if DOTNETCORE
129-
internal static bool IsAssignableFrom(this Type t, Type other) => t.GetTypeInfo().IsAssignableFrom(other.GetTypeInfo());
130-
#endif
131-
132-
internal static bool IsGeneric(this Type type)
133-
{
134-
#if DOTNETCORE
135-
return type.GetTypeInfo().IsGenericType;
136-
#else
137-
return type.IsGenericType;
138-
#endif
139-
}
140-
141-
internal static bool IsValue(this Type type)
142-
{
143-
#if DOTNETCORE
144-
return type.GetTypeInfo().IsValueType;
145-
#else
146-
return type.IsValueType;
147-
#endif
148-
}
149-
150-
internal static bool IsEnumType(this Type type)
151-
{
152-
#if DOTNETCORE
153-
return type.GetTypeInfo().IsEnum;
154-
#else
155-
return type.IsEnum;
156-
#endif
157-
}
158-
159-
#if DOTNETCORE
160-
internal static IEnumerable<Type> GetInterfaces(this Type type)
161-
{
162-
return type.GetTypeInfo().ImplementedInterfaces;
163-
}
164-
#endif
165127
}
166-
}
128+
}

src/Nest/CrossPlatform/TypeExtensions.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Reflection;
55
using System.Threading.Tasks;
66

7-
namespace Elasticsearch.Net
7+
namespace Nest
88
{
99
internal static class DotNetCoreTypeExtensions
1010
{
@@ -69,5 +69,25 @@ internal static TypeCode GetTypeCode(this Type type)
6969
return TypeCode.Object;
7070
#endif
7171
}
72+
73+
#if DOTNETCORE
74+
internal static bool IsAssignableFrom(this Type t, Type other) => t.GetTypeInfo().IsAssignableFrom(other.GetTypeInfo());
75+
#endif
76+
77+
internal static bool IsEnumType(this Type type)
78+
{
79+
#if DOTNETCORE
80+
return type.GetTypeInfo().IsEnum;
81+
#else
82+
return type.IsEnum;
83+
#endif
84+
}
85+
86+
#if DOTNETCORE
87+
internal static IEnumerable<Type> GetInterfaces(this Type type)
88+
{
89+
return type.GetTypeInfo().ImplementedInterfaces;
90+
}
91+
#endif
7292
}
7393
}

0 commit comments

Comments
 (0)