bfr/BFR/Operations/OperationType.cs
adroslice 704b7ea1a9 Added internal Operation Infrastructure + Example
- Overwrite might be a bad example, because it has no fail conditions. The intended behaviour for those is to throw an exception for invalid parameters, with an error text describing to the user what went wrong.
- Fail condition check may be moved to a seperate abstract method, forcing implementers to at least give fail conditions a thought.
- Minor refactor
- TODO: Better folder structure to group operations (Looking for suggestions)
2019-11-16 02:00:17 +01:00

21 lines
591 B
C#

using System;
namespace BFR.Operations
{
public class OperationType
{
public string Name { get; }
public string Description { get; }
public Func<Operation> Create { get; }
internal static OperationType Make<T>() where T : Operation, new()
{
var pilot = new T();
return new OperationType(pilot.Name, pilot.Description, () => new T());
}
private OperationType(string name, string description, Func<Operation> create) =>
(Name, Description, Create) = (name, description, create);
}
}