Exemplo n.º 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>
        /// Add common custom data of the controller.
        /// </summary>
        /// <typeparam name="TClass">Type of the controller.</typeparam>
        /// <param name="options">The options.</param>
        /// <param name="key">Key.</param>
        /// <param name="value">Value.</param>
        /// <returns>
        /// Returns <see cref="PerformanceMeterMvcOptions{TClass}"/>.
        /// </returns>
        public static PerformanceMeterMvcOptions <TClass> AddCustomData <TClass>(this PerformanceMeterMvcOptions <TClass> options, string key, object value) where TClass : ControllerBase
        {
            PerformanceMeter <TClass> .AddCustomData(key, value);

            return(options);
        }