/// <summary> /// Tries to parse the <see cref="ActionDisplayID"/> from a string. /// </summary> /// <param name="parser">The <see cref="Parser"/> to use.</param> /// <param name="value">The string to parse.</param> /// <param name="outValue">If this method returns true, contains the parsed <see cref="ActionDisplayID"/>.</param> /// <returns>True if the parsing was successfully; otherwise false.</returns> public static bool TryParse(this Parser parser, string value, out ActionDisplayID outValue) { ushort tmp; var ret = parser.TryParse(value, out tmp); outValue = new ActionDisplayID(tmp); return(ret); }
/// <summary> /// Gets the <see cref="ActionDisplay"/> with the given <see cref="ActionDisplayID"/>. /// </summary> /// <param name="id">The <see cref="ActionDisplayID"/> of the <see cref="ActionDisplay"/> to get.</param> /// <returns>The <see cref="ActionDisplay"/> at the given <paramref name="id"/>, or null if the <paramref name="id"/> /// was invalid or no <see cref="ActionDisplay"/> exists at the given ID.</returns> public ActionDisplay this[ActionDisplayID id] { get { if (!_items.CanGet((int)id)) { return(null); } return(_items[(int)id]); } }
/// <summary> /// Writes a <see cref="ActionDisplayID"/> to a <see cref="IValueWriter"/>. /// </summary> /// <param name="valueWriter"><see cref="IValueWriter"/> to write to.</param> /// <param name="name">Unique name of the <see cref="ActionDisplayID"/> that will be used to distinguish it /// from other values when reading.</param> /// <param name="value"><see cref="ActionDisplayID"/> to write.</param> public static void Write(this IValueWriter valueWriter, string name, ActionDisplayID value) { value.Write(valueWriter, name); }
/// <summary> /// Writes a <see cref="ActionDisplayID"/> to a <see cref="BitStream"/>. /// </summary> /// <param name="bitStream"><see cref="BitStream"/> to write to.</param> /// <param name="value"><see cref="ActionDisplayID"/> to write.</param> public static void Write(this BitStream bitStream, ActionDisplayID value) { value.Write(bitStream); }
/// <summary> /// Reads the <see cref="ActionDisplayID"/> from an IValueReader. /// </summary> /// <param name="valueReader"><see cref="IValueReader"/> to read the <see cref="ActionDisplayID"/> from.</param> /// <param name="name">The unique name of the value to read.</param> /// <returns>The <see cref="ActionDisplayID"/> read from the IValueReader.</returns> public static ActionDisplayID ReadActionDisplayID(this IValueReader valueReader, string name) { return(ActionDisplayID.Read(valueReader, name)); }
/// <summary> /// Reads the <see cref="ActionDisplayID"/> from a <see cref="BitStream"/>. /// </summary> /// <param name="bitStream"><see cref="BitStream"/> to read the <see cref="ActionDisplayID"/> from.</param> /// <returns>The <see cref="ActionDisplayID"/> read from the <see cref="BitStream"/>.</returns> public static ActionDisplayID ReadActionDisplayID(this BitStream bitStream) { return(ActionDisplayID.Read(bitStream)); }
/// <summary> /// Reads the <see cref="ActionDisplayID"/> from an <see cref="IDataRecord"/>. /// </summary> /// <param name="r"><see cref="IDataRecord"/> to read the <see cref="ActionDisplayID"/> from.</param> /// <param name="name">The name of the field to read the value from.</param> /// <returns>The <see cref="ActionDisplayID"/> read from the <see cref="IDataRecord"/>.</returns> public static ActionDisplayID GetActionDisplayID(this IDataRecord r, string name) { return(ActionDisplayID.Read(r, name)); }
/// <summary> /// Reads the <see cref="ActionDisplayID"/> from an <see cref="IDataRecord"/>. /// </summary> /// <param name="dataReader"><see cref="IDataRecord"/> to read the <see cref="ActionDisplayID"/> from.</param> /// <param name="i">The field index to read.</param> /// <returns>The <see cref="ActionDisplayID"/> read from the <see cref="IDataReader"/>.</returns> public static ActionDisplayID GetActionDisplayID(this IDataRecord dataReader, int i) { return(ActionDisplayID.Read(dataReader, i)); }
/// <summary> /// Tries to get the value in the <paramref name="dict"/> entry at the given <paramref name="key"/> as a /// <see cref="ActionDisplayID"/>. /// </summary> /// <typeparam name="T">The key Type.</typeparam> /// <param name="dict">The <see cref="IDictionary{TKey, TValue}"/>.</param> /// <param name="key">The key for the value to get.</param> /// <param name="defaultValue">The value to use if the value at the <paramref name="key"/> could not be parsed.</param> /// <returns>The value at the given <paramref name="key"/> parsed as an int, or the /// <paramref name="defaultValue"/> if the <paramref name="key"/> did not exist in the <paramref name="dict"/> /// or the value at the given <paramref name="key"/> could not be parsed.</returns> public static ActionDisplayID AsActionDisplayID <T>(this IDictionary <T, string> dict, T key, ActionDisplayID defaultValue) { string value; if (!dict.TryGetValue(key, out value)) { return(defaultValue); } ActionDisplayID parsed; if (!Parser.Invariant.TryParse(value, out parsed)) { return(defaultValue); } return(parsed); }
/// <summary> /// Initializes a new instance of the <see cref="ActionDisplay"/> class. /// </summary> /// <param name="id">The <see cref="ActionDisplayID"/>.</param> public ActionDisplay(ActionDisplayID id) { _id = id; }
/// <summary> /// Removes the item at the given <paramref name="id"/>. /// </summary> /// <param name="id">The ID of the item to remove.</param> public void RemoveAt(ActionDisplayID id) { _items.RemoveAt((int)id); }