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

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

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

            return(typeArgs.Last());
        }