/// <summary> /// Records a value to the values array of this sample given the zero-based index of the value definition to be used. /// </summary> /// <remarks>The value must be defined as part of the event metric definition associated with this sample /// or an exception will be thrown. The data type must also be compatible with the data type configured /// on the event metric definition or no data will be recorded. /// If called more than once for the same value, the prior value will be replaced.</remarks> /// <param name="valueIndex">The zero-based index within the value definition of the value to be recorded.</param> /// <param name="value">Optional. The value to be recorded.</param> public void SetValue(int valueIndex, object value) { EventMetricValueDefinitionCollection valueDefinitions = Metric.Definition.ValueCollection; //we don't have to check that the value index isn't null, but it does have to be in range if ((valueIndex < 0) || (valueIndex >= valueDefinitions.Count)) { #if DEBUG //if we're compiled in debug mode, tell the user they blew it. throw new ArgumentOutOfRangeException(nameof(valueIndex), valueIndex.ToString(CultureInfo.CurrentCulture)); #else //trace log and return, nothing we can do. Log.Warning("Unable to add metric value because the value definition could not be found.", "There is no value definition at index {1} for metric definition {0}", Metric.Definition.Key, valueIndex); return; #endif } //look up the value in the definition so we can process it EventMetricValueDefinition curValueDefinition = valueDefinitions[valueIndex]; //and now we can use our one true method to add the value SetValue(curValueDefinition, value); }
public Enumerator(EventMetricValueDefinitionCollection collection, IEnumerator <IEventMetricValueDefinition> enumerator) { m_Collection = collection; m_Enumerator = enumerator; }