/// <summary>
        /// Create a new value definition with the supplied name and type.  The name must be unique in this collection.
        /// </summary>
        /// <remarks>Internally, only simple type are supported.  Any non-numeric, non-DateTimeOffset type will be converted
        /// to a string using the default ToString capability when it is recorded.</remarks>
        /// <param name="name">The unique name for this value definition.</param>
        /// <param name="type">The simple type of this value.</param>
        /// <param name="summaryFunction">The default way that individual samples of this value column can be aggregated
        /// to create a graphable summary. (Use SummaryFunction.Count for non-numeric types.)</param>
        /// <param name="unitCaption">A displayable caption for the units this value represents, or null for unit-less values.</param>
        /// <param name="caption">The end-user display caption for this value.</param>
        /// <param name="description">The end-user description for this value.</param>
        /// <returns>The newly created value definition.</returns>
        /// <exception cref="ArgumentNullException">The provided name or type are null.</exception>
        /// <exception cref="ArgumentException">There is already a definition with the provided name</exception>
        public EventMetricValueDefinition Add(string name, Type type, SummaryFunction summaryFunction, string unitCaption, string caption, string description)
        {
            lock (m_Definition.Lock)
            {
                //if we are read-only, you can't add a new value
                if (IsReadOnly)
                {
                    throw new InvalidOperationException("The collection is read-only");
                }

                //make sure we got everything we require
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentNullException(nameof(name));
                }

                if (type == null)
                {
                    throw new ArgumentNullException(nameof(type));
                }

                //make sure the name is unique
                if (ContainsKey(name))
                {
                    throw new ArgumentException("There is already a value definition with the provided name.", nameof(name));
                }

                //create a new value definition
                EventMetricValueDefinition newDefinition = Externalize(m_WrappedCollection.Add(name, type, caption, description));
                newDefinition.SummaryFunction = summaryFunction;
                newDefinition.UnitCaption     = unitCaption;

                //and return the new object to our caller so the have the object we created from their input.
                return(newDefinition);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Set the default way that individual samples will be aggregated to create a graphable summary.
 /// </summary>
 /// <param name="summaryFunction">The new value for the SummaryFunction property.</param>
 internal void SetSummaryFunction(SummaryFunction summaryFunction)
 {
     m_SummaryFunction = summaryFunction;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Add the current field, property, or method as a value column in the event metric using its declared Type and the specified name, unit caption and summary function.
 /// </summary>
 /// <param name="name">The unique name of this value column within the event.</param>
 /// <param name="summaryFunction">An aggregation summary to best interpret this value column for graphing. (use SummaryFunction.Count for non-math types)</param>
 /// <param name="unitCaption">A displayable caption for the units this value represents, or null for unit-less values.</param>
 public EventMetricValueAttribute(string name, SummaryFunction summaryFunction, string unitCaption)
 {
     m_Name            = string.IsNullOrEmpty(name) ? name : name.Trim();
     m_UnitCaption     = string.IsNullOrEmpty(unitCaption) ? unitCaption : unitCaption.Trim();
     m_SummaryFunction = summaryFunction;
 }