/// <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(MetricPacket other) { //Careful - can be null if (other == null) { return(false); // since we're a live object we can't be equal. } return((InstanceName == other.InstanceName) && (DefinitionId == other.DefinitionId) && (base.Equals(other))); }
/// <summary> /// Create a new metric sample for the provided metric. /// </summary> /// <param name="metric">The metric this sample applies to</param> protected MetricSamplePacket(Metric metric) { if (metric == null) { throw new ArgumentNullException(nameof(metric)); } ID = Guid.NewGuid(); m_MetricPacket = metric.Packet; Persisted = false; }
/// <summary> /// Compare this object to another to determine sort order /// </summary> /// <param name="other"></param> /// <returns></returns> public int CompareTo(MetricPacket other) { //quick identity comparison based on guid if (ID == other.ID) { return(0); } //Now we try to stort by name. We already guard against uniqueness int compareResult = string.Compare(Name, other.Name, StringComparison.OrdinalIgnoreCase); return(compareResult); }