示例#1
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static PerformanceMeterController()
        {
            // set cache time for PerformanceMeterController class
            PerformanceMeter <PerformanceMeterController> .SetMethodCallsCacheTime(5);

            // add common custom data (string) to class performance information
            PerformanceMeter <PerformanceMeterController> .AddCustomData("Tag", "CustomTag");

            // add common custom data (anonymous class) to class performance information
            PerformanceMeter <PerformanceMeterController> .AddCustomData("Custom anonymous class", new { Name = "Custom Name", Value = 1 });

            // set default exception handler for PerformanceMeterController class
            PerformanceMeter <PerformanceMeterController> .SetDefaultExceptionHandler((ex) => Debug.WriteLine(ex.Message));
        }
        /// <summary>
        /// Set Action to handle exceptions that occur by default.
        /// </summary>
        /// <typeparam name="TClass">Type of the controller.</typeparam>
        /// <param name="options">The options.</param>
        /// <param name="exceptionHandler">Action to handle exceptions that occur.</param>
        /// <returns>
        /// Returns <see cref="PerformanceMeterMvcOptions{TClass}"/>.
        /// </returns>
        public static PerformanceMeterMvcOptions <TClass> SetDefaultExceptionHandler <TClass>(this PerformanceMeterMvcOptions <TClass> options, Action <Exception> exceptionHandler) where TClass : ControllerBase
        {
            PerformanceMeter <TClass> .SetDefaultExceptionHandler(exceptionHandler);

            return(options);
        }