Ejemplo n.º 1
0
        /// <summary>
        /// Create a new metric sample for the provided metric and raw sample packet
        /// </summary>
        /// <remarks>The metric sample is automatically added to the samples collection of the provided metric object.</remarks>
        /// <param name="metric">The specific metric this sample relates to</param>
        /// <param name="samplePacket">The raw sample packet to wrap.</param>
        internal MetricSample(Metric metric, MetricSamplePacket samplePacket)
        {
            //if we didn't get a metric or metric sample, we're toast.
            if (metric == null)
            {
                throw new ArgumentNullException(nameof(metric));
            }

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

            m_Metric             = metric;
            m_MetricSamplePacket = samplePacket;

            //we may need to correct the sample packet - this is due to the order objects are rehydrated in.
            if (m_MetricSamplePacket.MetricPacket == null)
            {
                m_MetricSamplePacket.MetricPacket = m_Metric.Packet;
            }

            //now add ourself to the metric's sample collection, if we aren't in collection mode
            if (((MetricDefinition)metric.Definition).IsLive == false)
            {
                metric.Samples.Add(this);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Invoked when deserializing a metric sample to allow inheritors to provide derived implementations
 /// </summary>
 /// <remarks>If you wish to provide a derived class for metric samples in your derived metric, use this
 /// method to create and return your derived object to support the deserialization process.
 /// This is used during object construction, so implementations should treat it as a static method.</remarks>
 /// <param name="packet">The metric sample packet being deserialized</param>
 /// <returns>The metric sample-compatible object.</returns>
 internal override MetricSample OnMetricSampleRead(MetricSamplePacket packet)
 {
     //create a custom sampled metric sample object
     return(new EventMetricSample(this, (EventMetricSamplePacket)packet));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Invoked when deserializing a metric sample to allow inheritors to provide derived implementations
 /// </summary>
 /// <remarks>If you wish to provide a derived class for metric samples in your derived metric, use this
 /// method to create and return your derived object to support the deserialization process.
 /// This is used during object construction, so implementations should treat it as a static method.</remarks>
 /// <param name="packet">The metric sample packet being deserialized</param>
 /// <returns>The metric sample-compatible object.</returns>
 protected override MetricSample OnMetricSampleRead(MetricSamplePacket packet)
 {
     //create a custom sampled metric sample object
     return(new CustomSampledMetricSample(this, (CustomSampledMetricSamplePacket)packet));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Invoked when deserializing a metric sample to allow inheritors to provide derived implementations
 /// </summary>
 /// <remarks>If you wish to provide a derived class for metric samples in your derived metric, use this
 /// method to create and return your derived object to support the deserialization process.
 /// This is used during object construction, so implementations should treat it as a static method.</remarks>
 /// <param name="packet">The metric sample packet being deserialized</param>
 /// <returns>The metric sample-compatible object.</returns>
 internal abstract MetricSample OnMetricSampleRead(MetricSamplePacket packet);
Ejemplo n.º 5
0
 /// <summary>
 /// Invoked when deserializing a metric sample to allow inheritors to provide derived implementations
 /// </summary>
 /// <remarks>If you wish to provide a derived class for metric samples in your derived metric, use this
 /// method to create and return your derived object to support the deserialization process.
 /// This is used during object construction, so implementations should treat it as a static method.</remarks>
 /// <param name="packet">The metric sample packet being deserialized</param>
 /// <returns>The metric sample-compatible object.</returns>
 protected abstract MetricSample OnMetricSampleRead(MetricSamplePacket packet);