コード例 #1
0
/// <summary>
/// Sets the <paramref name="value"/> of a column by the database column's name.
/// </summary>
/// <param name="columnName">The database name of the column to get the <paramref name="value"/> for.</param>
/// <param name="value">Value to assign to the column.</param>
        public void SetValue(System.String columnName, System.Object value)
        {
            switch (columnName)
            {
            case "character_id":
                this.CharacterID = (DemoGame.CharacterID)value;
                break;

            case "item_id":
                this.ItemID = (DemoGame.ItemID)value;
                break;

            case "slot":
                this.Slot = (NetGore.InventorySlot)value;
                break;

            default:
                throw new ArgumentException("Field not found.", "columnName");
            }
        }
コード例 #2
0
 /// <summary>
 /// Writes a InventorySlot to a IValueWriter.
 /// </summary>
 /// <param name="valueWriter">IValueWriter to write to.</param>
 /// <param name="name">Unique name of the InventorySlot that will be used to distinguish it
 /// from other values when reading.</param>
 /// <param name="value">InventorySlot to write.</param>
 public static void Write(this IValueWriter valueWriter, string name, InventorySlot value)
 {
     value.Write(valueWriter, name);
 }
コード例 #3
0
 /// <summary>
 /// Writes a InventorySlot to a BitStream.
 /// </summary>
 /// <param name="bitStream">BitStream to write to.</param>
 /// <param name="value">InventorySlot to write.</param>
 public static void Write(this BitStream bitStream, InventorySlot value)
 {
     value.Write(bitStream);
 }
コード例 #4
0
 /// <summary>
 /// Reads the InventorySlot from an IValueReader.
 /// </summary>
 /// <param name="valueReader">IValueReader to read the InventorySlot from.</param>
 /// <param name="name">The unique name of the value to read.</param>
 /// <returns>The InventorySlot read from the IValueReader.</returns>
 public static InventorySlot ReadInventorySlot(this IValueReader valueReader, string name)
 {
     return(InventorySlot.Read(valueReader, name));
 }
コード例 #5
0
 /// <summary>
 /// Reads the InventorySlot from a BitStream.
 /// </summary>
 /// <param name="bitStream">BitStream to read the InventorySlot from.</param>
 /// <returns>The InventorySlot read from the BitStream.</returns>
 public static InventorySlot ReadInventorySlot(this BitStream bitStream)
 {
     return(InventorySlot.Read(bitStream));
 }
コード例 #6
0
 /// <summary>
 /// Reads the InventorySlot from an <see cref="IDataRecord"/>.
 /// </summary>
 /// <param name="r"><see cref="IDataRecord"/> to read the InventorySlot from.</param>
 /// <param name="name">The name of the field to read the value from.</param>
 /// <returns>The InventorySlot read from the <see cref="IDataRecord"/>.</returns>
 public static InventorySlot GetInventorySlot(this IDataRecord r, string name)
 {
     return(InventorySlot.Read(r, name));
 }
コード例 #7
0
 /// <summary>
 /// Reads the InventorySlot from an <see cref="IDataRecord"/>.
 /// </summary>
 /// <param name="r"><see cref="IDataRecord"/> to read the InventorySlot from.</param>
 /// <param name="i">The field index to read.</param>
 /// <returns>The InventorySlot read from the <see cref="IDataRecord"/>.</returns>
 public static InventorySlot GetInventorySlot(this IDataRecord r, int i)
 {
     return(InventorySlot.Read(r, i));
 }
コード例 #8
0
        /// <summary>
        /// Tries to get the value in the <paramref name="dict"/> entry at the given <paramref name="key"/> as type InventorySlot.
        /// </summary>
        /// <typeparam name="T">The key Type.</typeparam>
        /// <param name="dict">The IDictionary.</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 InventorySlot AsInventorySlot <T>(this IDictionary <T, string> dict, T key, InventorySlot defaultValue)
        {
            string value;

            if (!dict.TryGetValue(key, out value))
            {
                return(defaultValue);
            }

            InventorySlot parsed;

            if (!Parser.Invariant.TryParse(value, out parsed))
            {
                return(defaultValue);
            }

            return(parsed);
        }
コード例 #9
0
/// <summary>
/// Sets the <paramref name="value"/> of a column by the database column's name.
/// </summary>
/// <param name="columnName">The database name of the column to get the <paramref name="value"/> for.</param>
/// <param name="value">Value to assign to the column.</param>
public void SetValue(System.String columnName, System.Object value)
{
switch (columnName)
{
case "character_id":
this.CharacterID = (DemoGame.CharacterID)value;
break;

case "item_id":
this.ItemID = (DemoGame.ItemID)value;
break;

case "slot":
this.Slot = (NetGore.InventorySlot)value;
break;

default:
throw new ArgumentException("Field not found.","columnName");
}
}
コード例 #10
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this CharacterInventoryTable.
/// </summary>
/// <param name="source">The ICharacterInventoryTable to copy the values from.</param>
public void CopyValuesFrom(ICharacterInventoryTable source)
{
this.CharacterID = (DemoGame.CharacterID)source.CharacterID;
this.ItemID = (DemoGame.ItemID)source.ItemID;
this.Slot = (NetGore.InventorySlot)source.Slot;
}
コード例 #11
0
/// <summary>
/// Initializes a new instance of the <see cref="CharacterInventoryTable"/> class.
/// </summary>
/// <param name="characterID">The initial value for the corresponding property.</param>
/// <param name="itemID">The initial value for the corresponding property.</param>
/// <param name="slot">The initial value for the corresponding property.</param>
public CharacterInventoryTable(DemoGame.CharacterID @characterID, DemoGame.ItemID @itemID, NetGore.InventorySlot @slot)
{
this.CharacterID = (DemoGame.CharacterID)@characterID;
this.ItemID = (DemoGame.ItemID)@itemID;
this.Slot = (NetGore.InventorySlot)@slot;
}
コード例 #12
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this CharacterInventoryTable.
/// </summary>
/// <param name="source">The ICharacterInventoryTable to copy the values from.</param>
        public void CopyValuesFrom(ICharacterInventoryTable source)
        {
            this.CharacterID = (DemoGame.CharacterID)source.CharacterID;
            this.ItemID      = (DemoGame.ItemID)source.ItemID;
            this.Slot        = (NetGore.InventorySlot)source.Slot;
        }
コード例 #13
0
/// <summary>
/// Initializes a new instance of the <see cref="CharacterInventoryTable"/> class.
/// </summary>
/// <param name="characterID">The initial value for the corresponding property.</param>
/// <param name="itemID">The initial value for the corresponding property.</param>
/// <param name="slot">The initial value for the corresponding property.</param>
        public CharacterInventoryTable(DemoGame.CharacterID @characterID, DemoGame.ItemID @itemID, NetGore.InventorySlot @slot)
        {
            this.CharacterID = (DemoGame.CharacterID)@characterID;
            this.ItemID      = (DemoGame.ItemID)@itemID;
            this.Slot        = (NetGore.InventorySlot)@slot;
        }