Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeMeasureAttribute" /> class.
 /// </summary>
 /// <param name="threshold">The <see cref="double" /> value that in combination with <paramref name="thresholdTimeUnit" /> specifies the threshold of the action method.</param>
 /// <param name="thresholdTimeUnit">One of the enumeration values that specifies the time unit of <paramref name="threshold" />.</param>
 public TimeMeasureAttribute(double threshold, TimeUnit thresholdTimeUnit)
 {
     Setup = options =>
     {
         options.TimeMeasureCompletedThreshold = TimeSpanConverter.FromDouble(threshold, thresholdTimeUnit);
     };
 }
        /// <summary>
        /// Creates an instance of the executable filter.
        /// </summary>
        /// <param name="serviceProvider">The request <see cref="IServiceProvider" />.</param>
        /// <returns>An instance of the executable filter.</returns>
        public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
        {
            var he = serviceProvider.GetRequiredService <IHostingEnvironment>();

            return(new TimeMeasuringFilter(Options.Create(new TimeMeasuringOptions()
            {
                TimeMeasureCompletedThreshold = TimeSpanConverter.FromDouble(Threshold, ThresholdTimeUnit)
            }), he));
        }