Example #1
0
        private static void CreateWithFilters(
            CreateContext context,
            IEnumerable <IClientFilter> filters)
        {
            var preContext = new CreatingContext(context);
            Func <CreatedContext> continuation = () =>
            {
                context.CreateJob();
                return(new CreatedContext(context, false, null));
            };

            var thunk = filters.Reverse().Aggregate(continuation,
                                                    (next, filter) => () => InvokeClientFilter(filter, preContext, next));

            thunk();
        }
Example #2
0
        public void Run(CreateContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var filterInfo = GetFilters(context.Job);

            try
            {
                CreateWithFilters(context, filterInfo.ClientFilters);
            }
            catch (Exception ex)
            {
                var exceptionContext = new ClientExceptionContext(context, ex);

                InvokeExceptionFilters(exceptionContext, filterInfo.ClientExceptionFilters);
                if (!exceptionContext.ExceptionHandled)
                {
                    throw;
                }
            }
        }