コード例 #1
0
        /// <summary>
        /// Converts from recipe to model.
        /// </summary>
        /// <param name="description">Recipe description.</param>
        /// <returns>Model description.</returns>
        public static PerformanceCounterDescription FromRecipe(this RecipePerformanceCounterDescription description)
        {
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            return(description.ToModel());
        }
コード例 #2
0
        /// <summary>
        /// Converts from recipe to model.
        /// </summary>
        /// <param name="description">Recipe description.</param>
        /// <returns>Model description.</returns>
        public static PerformanceCounterDescription ToModel(this RecipePerformanceCounterDescription description)
        {
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            var result = new PerformanceCounterDescription(description.CategoryName, description.CounterName, description.InstanceName, description.ExpectedMinValue, description.ExpectedMaxValue);

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Samples the provided performance counter.
        /// </summary>
        /// <param name="description">Description to query with.</param>
        /// <returns>Description and sample in one object.</returns>
        public static RecipePerformanceCounterSample Sample(this RecipePerformanceCounterDescription description)
        {
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            var nextValue = SampleNextValueOnPerformanceCounter(description.CategoryName, description.CounterName, description.InstanceName);
            var result    = new RecipePerformanceCounterSample(description, nextValue);

            return(result);
        }