/// <summary> /// Gets the index to the fields array given a field tag. /// </summary> /// <param name="tag">a field tag as defined in <c>QuoteFieldTags</c>.</param> /// <returns>The index in the fields array or -1 if the field doesn't exist.</returns> /// <exception cref="System.ArgumentOutOfRangeException">The input tag is out of range.</exception> public override int GetIndexFromTag(QuoteFieldTags tag) { int index = (int)tag; if (index < 0 || index >= m_tagToIndex.Length) { throw new ArgumentOutOfRangeException("tag out of range."); } return(m_tagToIndex[index]); }
/// <summary> /// Gets the index to the fields array given a field tag. /// </summary> /// <param name="tag">a field tag as defined in <c>QuoteFieldTags</c>.</param> /// <returns>The index in the fields array or -1 if the field doesn't exist.</returns> public override int GetIndexFromTag(QuoteFieldTags tag) { switch (tag) { case QuoteFieldTags.UpdateTimestamp: return(0); case QuoteFieldTags.AuctionSession: return(1); case QuoteFieldTags.ContentText: return(2); default: Debug.Assert(false, "Unsupported tag."); return(-1); } }
/// <summary> /// Gets the index to the fields array given a field tag. /// </summary> /// <param name="tag">a field tag as defined in <c>QuoteFieldTags</c>.</param> /// <returns>The index in the fields array or -1 if the field doesn't exist.</returns> public abstract int GetIndexFromTag(QuoteFieldTags tag);
/// <summary> /// Gets the TimeSpan value associated with the specified tag. /// </summary> /// <param name="tag">a tag representing a field of this message.</param> /// <returns>The TimeSpan value associated with the tag or <c>TimeSpan.Zero</c>.</returns> public TimeSpan GetFieldValueAsTimeSpan(QuoteFieldTags tag) { return(GetFieldValueAsTimeSpan(tag, TimeSpan.Zero)); }
/// <summary> /// Gets the string value associated with the specified tag. /// </summary> /// <param name="tag">a tag representing a field of this message.</param> /// <returns>The string value associated with the tag.</returns> public string GetFieldValueAsString(QuoteFieldTags tag) { return(GetFieldValueAsString(GetIndexFromTag(tag))); }
/// <summary> /// Gets the TimeSpan value associated with the specified tag. /// </summary> /// <param name="tag">a tag representing a field of this message.</param> /// <param name="defaultValue">the default value to return if the field doesn't exist or the retrieved string is empty.</param> /// <returns>The TimeSpan value associated with the tag or <c>defaultValue</c>.</returns> public TimeSpan GetFieldValueAsTimeSpan(QuoteFieldTags tag, TimeSpan defaultValue) { return(GetFieldValueAsTimeSpan(GetIndexFromTag(tag), defaultValue)); }
/// <summary> /// Gets the DateTime value associated with the specified tag. /// </summary> /// <param name="tag">a tag representing a field of this message.</param> /// <returns>The DateTime value associated with the tag or <c>DateTime.MinValue</c>.</returns> public DateTime GetFieldValueAsDateTime(QuoteFieldTags tag) { return(GetFieldValueAsDateTime(tag, DateTime.MinValue)); }
/// <summary> /// Gets the DateTime value associated with the specified tag. /// </summary> /// <param name="tag">a tag representing a field of this message.</param> /// <param name="defaultValue">the default value to return if the field doesn't exist or the retrieved string is empty.</param> /// <returns>The DateTime value associated with the tag or <c>defaultValue</c>.</returns> public DateTime GetFieldValueAsDateTime(QuoteFieldTags tag, DateTime defaultValue) { return(GetFieldValueAsDateTime(GetIndexFromTag(tag), defaultValue)); }
/// <summary> /// Gets the Int32 value associated with the specified tag. /// </summary> /// <param name="tag">a tag representing a field of this message.</param> /// <returns>The int value associated with the tag or 0.</returns> public int GetFieldValueAsInt32(QuoteFieldTags tag) { return(GetFieldValueAsInt32(tag, 0)); }
/// <summary> /// Gets the Int32 value associated with the specified tag. /// </summary> /// <param name="tag">a tag representing a field of this message.</param> /// <param name="defaultValue">the default value to return if the field doesn't exist or the retrieved string is empty.</param> /// <returns>The int value associated with the tag or <c>defaultValue</c>.</returns> public int GetFieldValueAsInt32(QuoteFieldTags tag, int defaultValue) { return(GetFieldValueAsInt32(GetIndexFromTag(tag), defaultValue)); }