예제 #1
0
        public static void Register(MathOperation operation)
        {
            if (Has(operation.OperationType, MathOperation.GetOperandTypes(operation)))
            {
                throw new InvalidOperationException("");
            }

            registeredOperations.Add(operation);
        }
예제 #2
0
 public static List <MathOperation> GetAll(Type[] operandTypes) =>
 registeredOperations.FindAll(o => Enumerable.SequenceEqual(MathOperation.GetOperandTypes(o),
                                                            operandTypes));
예제 #3
0
 public static void Unregister(MathOperation operation) => registeredOperations.Remove(operation);
예제 #4
0
        public static Type[] GetOperandTypes(MathOperation operation)
        {
            var typeArgs = operation.GetType().GenericTypeArguments;

            return(typeArgs.Take(typeArgs.Length - 1).ToArray());
        }
예제 #5
0
        public static Type GetResultType(MathOperation operation)
        {
            var typeArgs = operation.GetType().GenericTypeArguments;

            return(typeArgs.Last());
        }