/// <summary>
        /// Converts from recipe to model.
        /// </summary>
        /// <param name="sample">Recipe sample.</param>
        /// <returns>Model description.</returns>
        public static PerformanceCounterSample FromRecipe(this RecipePerformanceCounterSample sample)
        {
            if (sample == null)
            {
                throw new ArgumentNullException(nameof(sample));
            }

            return(sample.ToModel());
        }
        /// <summary>
        /// Converts from recipe to model.
        /// </summary>
        /// <param name="sample">Recipe sample.</param>
        /// <returns>Model description.</returns>
        public static PerformanceCounterSample ToModel(this RecipePerformanceCounterSample sample)
        {
            if (sample == null)
            {
                throw new ArgumentNullException(nameof(sample));
            }

            var result = new PerformanceCounterSample(sample.Description.ToModel(), sample.Value);

            return(result);
        }
Exemplo n.º 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);
        }