Ejemplo n.º 1
0
        /// <summary>
        /// Executes an expression inside a try/catch block to avoid throwing of exception. This expression is being
        /// executed inside a ResumeNext statement, for instance a condition of if, while, for, etc.
        /// </summary>
        /// <typeparam name="T">The type of the class being created</typeparam>
        /// <param name="ex">An Exception if any is thrown executing the expression or null if not.</param>
        /// <param name="expr">The expression to be executed in a try/catch block.</param>
        public static T ResumeNextExpr <T>(out Exception ex, ResumeNextExprDelegate expr)
        {
            T result = default(T);

            ex = null;
            try
            {
                result = (T)expr.Invoke();
            }
            catch (Exception e)
            {
                ex = e;
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes an expression inside a try/catch block to avoid throwing of exception. This expression is being
        /// executed inside a ResumeNext statement, for instance a condition of if, while, for, etc.
        /// </summary>
        /// <typeparam name="T">The type of the class being created</typeparam>
        /// <param name="expr">The expression to be executed in a try/catch block.</param>
        public static T ResumeNextExpr <T>(ResumeNextExprDelegate expr)
        {
            Exception ex = null;

            return(ResumeNextExpr <T>(out ex, expr));
        }