Skip to content

Commit 46ab5a5

Browse files
committed
Moving type extensions to their own class
1 parent 79c1a6c commit 46ab5a5

File tree

3 files changed

+40
-30
lines changed

3 files changed

+40
-30
lines changed

src/FluentAssertions.Ioc.Ninject/AssemblyExtensions.cs

-30
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,5 @@ public static IEnumerable<Type> GetAllInterfaces(this Assembly assembly)
2424
{
2525
return assembly.GetTypes().Where(x => x.IsInterface);
2626
}
27-
28-
/// <summary>
29-
/// Filters for just the types in the specified namespace.
30-
/// </summary>
31-
/// <typeparam name="T">The namespace of this type.</typeparam>
32-
/// <param name="types">The types to filter.</param>
33-
public static IEnumerable<Type> InNamespaceOf<T>(this IEnumerable<Type> types)
34-
{
35-
return types.Where(x => x.Namespace == typeof(T).Namespace);
36-
}
37-
38-
/// <summary>
39-
/// Filters to exclude the specified type.
40-
/// </summary>
41-
/// <typeparam name="T">The type to exclude.</typeparam>
42-
/// <param name="types">The types to filter.</param>
43-
public static IEnumerable<Type> Excluding<T>(this IEnumerable<Type> types)
44-
{
45-
return types.Where(x => x.Name != typeof(T).Name);
46-
}
47-
48-
/// <summary>
49-
/// Filters to only include types where the type name ends with the specified string.
50-
/// </summary>
51-
/// <param name="types">The types to filter.</param>
52-
/// <param name="endingWith">The ending with string.</param>
53-
public static IEnumerable<Type> EndingWith(this IEnumerable<Type> types, string endingWith)
54-
{
55-
return types.Where(x => x.Name.EndsWith(endingWith));
56-
}
5727
}
5828
}

src/FluentAssertions.Ioc.Ninject/FluentAssertions.Ioc.Ninject.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<Compile Include="KernelExtensions.cs" />
6262
<Compile Include="Properties\AssemblyInfo.cs" />
6363
<Compile Include="SingleTypeKernelAssertions.cs" />
64+
<Compile Include="TypeExtensions.cs" />
6465
</ItemGroup>
6566
<ItemGroup>
6667
<None Include="FluentAssertions.Ioc.Ninject.nuspec" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace FluentAssertions.Ioc.Ninject
6+
{
7+
public static class TypeExtensions
8+
{
9+
/// <summary>
10+
/// Filters for just the types in the specified namespace.
11+
/// </summary>
12+
/// <typeparam name="T">The namespace of this type.</typeparam>
13+
/// <param name="types">The types to filter.</param>
14+
public static IEnumerable<Type> InNamespaceOf<T>(this IEnumerable<Type> types)
15+
{
16+
return types.Where(x => x.Namespace == typeof(T).Namespace);
17+
}
18+
19+
/// <summary>
20+
/// Filters to exclude the specified type.
21+
/// </summary>
22+
/// <typeparam name="T">The type to exclude.</typeparam>
23+
/// <param name="types">The types to filter.</param>
24+
public static IEnumerable<Type> Excluding<T>(this IEnumerable<Type> types)
25+
{
26+
return types.Where(x => x.Name != typeof(T).Name);
27+
}
28+
29+
/// <summary>
30+
/// Filters to only include types where the type name ends with the specified string.
31+
/// </summary>
32+
/// <param name="types">The types to filter.</param>
33+
/// <param name="endingWith">The ending with string.</param>
34+
public static IEnumerable<Type> EndingWith(this IEnumerable<Type> types, string endingWith)
35+
{
36+
return types.Where(x => x.Name.EndsWith(endingWith));
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)