forked from giacomelli/GeneticSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrossoverService.cs
56 lines (52 loc) · 2 KB
/
CrossoverService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using GeneticSharp.Infrastructure.Framework.Reflection;
namespace GeneticSharp.Domain.Crossovers
{
/// <summary>
/// Crossover service.
/// </summary>
public static class CrossoverService
{
#region Methods
/// <summary>
/// Gets available crossover types.
/// </summary>
/// <returns>All available crossover types.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public static IList<Type> GetCrossoverTypes()
{
return TypeHelper.GetTypesByInterface<ICrossover>();
}
/// <summary>
/// Gets the available crossover names.
/// </summary>
/// <returns>The crossover names.</returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public static IList<string> GetCrossoverNames()
{
return TypeHelper.GetDisplayNamesByInterface<ICrossover>();
}
/// <summary>
/// Creates the ICrossover's implementation with the specified name.
/// </summary>
/// <returns>The crossover implementation instance.</returns>
/// <param name="name">The crossover name.</param>
/// <param name="constructorArgs">Constructor arguments.</param>
public static ICrossover CreateCrossoverByName(string name, params object[] constructorArgs)
{
return TypeHelper.CreateInstanceByName<ICrossover>(name, constructorArgs);
}
/// <summary>
/// Gets the crossover type by the name.
/// </summary>
/// <returns>The crossover type.</returns>
/// <param name="name">The name of crossover.</param>
public static Type GetCrossoverTypeByName(string name)
{
return TypeHelper.GetTypeByName<ICrossover>(name);
}
#endregion
}
}