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

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

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

            return(typeArgs.Last());
        }