static bool CanDoOperation <O>(O candidate, string operationName, object[] parameters)
        {
            var member = MemberQuery.GetDirectInstance(candidate,
                                                       new MemberSpecification("Can" + operationName, parameters.Length));

            return(member.Invoke(parameters).GetValue <bool>());
        }
Example #2
0
        public TypedValue Operate <O>(params object[] parameters) where O : class
        {
            var operationType = typeof(O).Name;
            var operationName = operationType.Substring(0, operationType.IndexOf("Operator"));
            var logging       = new OperationLogging(Memory);

            try {
                logging.Start(operationName);
                logging.LogParameters(parameters);
                var candidate = Operators.FindOperator <O>(parameters);
                var member    = MemberQuery.GetDirectInstance(candidate,
                                                              new MemberSpecification(operationName, parameters.Length));
                var result = member.Invoke(parameters).GetValue <TypedValue>();
                logging.LogResult(candidate, result);
                return(result);
            }
            finally {
                logging.End();
            }
        }