/// <summary>
 /// Creates an event metric definition packet for the provided event metric information
 /// </summary>
 /// <param name="definition">The event metric definition for this value.</param>
 /// <param name="name">The unique name of this event value within the definition.</param>
 /// <param name="type">The simple type of the data being stored in this value.</param>
 /// <param name="caption">The end-user display caption for this value</param>
 /// <param name="description">The end-user description for this value.</param>
 public EventMetricValueDefinitionPacket(EventMetricDefinitionPacket definition, string name, Type type, string caption, string description)
     : base(false)
 {
     m_EventDefinitionPacketId = definition.ID;
     ID     = Guid.NewGuid();
     m_Name = name;
     SetType(type);
     m_Caption     = caption;
     m_Description = description;
 }
        /// <summary>
        /// Creates an event metric definition packet for the provided event metric information
        /// </summary>
        /// <param name="definition">The event metric definition for this value.</param>
        /// <param name="name">The unique name of this event value within the definition.</param>
        /// <param name="type">The simple type of the data being stored in this value.</param>
        public EventMetricValueDefinitionPacket(EventMetricDefinitionPacket definition, string name, Type type)
            : base(false)
        {
            m_EventDefinitionPacketId = definition.ID;
            m_Name = name;
            SetType(type);
            m_Caption = name;

            //TODO: see if we can get a caption & description from the type by reflection
        }
        /// <summary>
        /// The list of packets that this packet depends on.
        /// </summary>
        /// <returns>An array of IPackets, or null if there are no dependencies.</returns>
        IPacket[] IPacket.GetRequiredPackets()
        {
            //we need to add in required packets for the metric definition values.  If we don't,
            //they will never get written out.
            EventMetricDefinitionPacket metricDefinitionPacket = (EventMetricDefinitionPacket)DefinitionPacket;

            IPacket[] requiredPackets = new IPacket[metricDefinitionPacket.MetricValues.Count];

            for (int curValueIndex = 0; curValueIndex < metricDefinitionPacket.MetricValues.Count; curValueIndex++)
            {
                requiredPackets[curValueIndex] = ((EventMetricValueDefinition)metricDefinitionPacket.MetricValues[curValueIndex]).Packet;
            }

            return(requiredPackets);
        }
        public IPacket CreatePacket(PacketDefinition definition, IFieldReader reader)
        {
            IPacket packet;

            if (definition.TypeName == m_SampledMetricDefinitionPacketType)
            {
                //sampled metrics can't be created directly - they're an abstract class.
                throw new ArgumentOutOfRangeException(nameof(definition), definition.TypeName, "Sampled Metric objects can't be created, only derived classes can.");
            }

            //what we create varies by what specific definition they're looking for
            if (definition.TypeName == m_MetricDefinitionPacketType)
            {
                packet = new MetricDefinitionPacket(m_Session);
            }
            else if (definition.TypeName == m_EventMetricDefinitionPacketType)
            {
                packet = new EventMetricDefinitionPacket(m_Session);
            }
            else if (definition.TypeName == m_EventMetricValueDefinitionPacketType)
            {
                packet = new EventMetricValueDefinitionPacket(m_Session);
            }
            else if (definition.TypeName == m_CustomSampledMetricDefinitionPacketType)
            {
                packet = new CustomSampledMetricDefinitionPacket(m_Session);
            }
            else
            {
                //crap, we don't know what to do here.
                throw new ArgumentOutOfRangeException(nameof(definition), definition.TypeName, "This packet factory doesn't undersatnd how to create packets for the provided type.");
            }

            //this feels a little crazy, but you have to do your own read call here - we aren't just creating the packet
            //object, we actually have to make the standard call to have it read data...
            definition.ReadFields(packet, reader);

            return(packet);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Determines if the provided object is identical to this object.
 /// </summary>
 /// <param name="other">The object to compare this object to</param>
 /// <returns>True if the objects represent the same data.</returns>
 public bool Equals(EventMetricDefinitionPacket other)
 {
     //We're really just a type cast, refer to our base object
     return(base.Equals(other));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Compare this event metric definition packet with another.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public int CompareTo(EventMetricDefinitionPacket other)
 {
     //we just gateway to our base object.
     return(base.CompareTo(other));
 }
 /// <summary>
 /// Create a new event metric packet for the provided metric definition and a specific instance.
 /// </summary>
 /// <param name="metricDefinitionPacket">The metric definition packet that defines this metric</param>
 /// <param name="instanceName">The unique instance name of this metric or null for the default instance.</param>
 public EventMetricPacket(EventMetricDefinitionPacket metricDefinitionPacket, string instanceName)
     : base(metricDefinitionPacket, instanceName)
 {
 }