Exemplo n.º 1
0
        /// <summary>
        /// Dispatches work into appropriate handler passing through filters.
        /// The default implementation processes requests on the calling thread and disposes WorkContext deterministically
        /// </summary>
        public virtual void Dispatch(WorkContext work)
        {
            WorkFilter  filter  = null;
            WorkHandler handler = null;

            try
            {
                var filters = m_Filters.OrderedValues.ToList().AsReadOnly();//captures context
                filter = filters.FirstOrDefault();
                if (filter != null)
                {
                    filter.FilterWork(work, filters, 0);
                }
                else
                {
                    InvokeHandler(work, out handler);
                }
            }
            catch (Exception error)
            {
                work.LastError = error;
                HandleException(work, filter, handler, error);
            }
            finally
            {
                try
                {
                    if (!work.NoDefaultAutoClose)
                    {
                        work.Dispose();
                    }
                }
                catch (Exception error)
                {
                    HandleException(null, null, null, error);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Handles processing exception - this implementation uses server-wide behavior.
 /// All parameters except ERROR can be null - which indicates error that happened during WorkContext dispose
 /// </summary>
 public virtual void HandleException(WorkContext work, WorkFilter filter, WorkHandler handler, Exception error)
 {
     ComponentDirector.HandleException(work, filter, handler, error);
 }