Exemplo n.º 1
0
        public ExecutionResult Execute(string hookType, IHooksStrategy strategy, IList <string> applicableTags,
                                       ExecutionContext context)
        {
            var methods         = GetHookMethods(hookType, strategy, applicableTags);
            var executionResult = new ExecutionResult
            {
                Success = true
            };

            foreach (var method in methods)
            {
                var methodInfo = _registry.MethodFor(method);
                try
                {
                    ExecuteHook(methodInfo, context);
                }
                catch (Exception ex)
                {
                    LogManager.GetLogger("HookExecutor").Debug("{0} Hook execution failed : {1}.{2}", hookType,
                                                               methodInfo.DeclaringType.FullName, methodInfo.Name);
                    var innerException = ex.InnerException ?? ex;
                    executionResult.ExceptionMessage = innerException.Message;
                    executionResult.StackTrace       = innerException.StackTrace;
                    executionResult.Source           = innerException.Source;
                    executionResult.Success          = false;
                }
            }

            return(executionResult);
        }
Exemplo n.º 2
0
        private IEnumerable <string> GetHookMethods(string hookType, IHooksStrategy strategy,
                                                    IEnumerable <string> applicableTags)
        {
            var hooksFromRegistry = GetHooksFromRegistry(hookType);

            return(strategy.GetApplicableHooks(applicableTags, hooksFromRegistry));
        }