コード例 #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());
        }