/// <summary>
        /// Copies the column values into the given DbParameterValues using the database column name
        /// with a prefixed @ as the key. The key must already exist in the DbParameterValues
        /// for the value to be copied over. If any of the keys in the DbParameterValues do not
        /// match one of the column names, or if there is no field for a key, then it will be
        /// ignored. Because of this, it is important to be careful when using this method
        /// since columns or keys can be skipped without any indication.
        /// </summary>
        /// <param name="source">The object to copy the values from.</param>
        /// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void TryCopyValues(this IShopTable source, DbParameterValues paramValues)
        {
            for (var i = 0; i < paramValues.Count; i++)
            {
                switch (paramValues.GetParameterName(i))
                {
                case "can_buy":
                    paramValues[i] = source.CanBuy;
                    break;

                case "id":
                    paramValues[i] = (UInt16)source.ID;
                    break;

                case "name":
                    paramValues[i] = source.Name;
                    break;
                }
            }
        }
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The key must already exist in the DbParameterValues
/// for the value to be copied over. If any of the keys in the DbParameterValues do not
/// match one of the column names, or if there is no field for a key, then it will be
/// ignored. Because of this, it is important to be careful when using this method
/// since columns or keys can be skipped without any indication.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void TryCopyValues(this IShopTable source, NetGore.Db.DbParameterValues paramValues)
        {
            for (int i = 0; i < paramValues.Count; i++)
            {
                switch (paramValues.GetParameterName(i))
                {
                case "can_buy":
                    paramValues[i] = (System.Boolean)source.CanBuy;
                    break;


                case "id":
                    paramValues[i] = (System.UInt16)source.ID;
                    break;


                case "name":
                    paramValues[i] = (System.String)source.Name;
                    break;
                }
            }
        }
示例#3
0
 /// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(IShopTable source, IDictionary <String, Object> dic)
 {
     dic["can_buy"] = source.CanBuy;
     dic["id"]      = source.ID;
     dic["name"]    = source.Name;
 }
示例#4
0
文件: ShopTable.cs 项目: wtfcolt/game
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this ShopTable.
/// </summary>
/// <param name="source">The IShopTable to copy the values from.</param>
public void CopyValuesFrom(IShopTable source)
{
this.CanBuy = (System.Boolean)source.CanBuy;
this.ID = (NetGore.Features.Shops.ShopID)source.ID;
this.Name = (System.String)source.Name;
}
示例#5
0
文件: ShopTable.cs 项目: wtfcolt/game
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
public static void CopyValues(IShopTable source, System.Collections.Generic.IDictionary<System.String,System.Object> dic)
{
dic["can_buy"] = (System.Boolean)source.CanBuy;
dic["id"] = (NetGore.Features.Shops.ShopID)source.ID;
dic["name"] = (System.String)source.Name;
}
示例#6
0
文件: ShopTable.cs 项目: wtfcolt/game
/// <summary>
/// Initializes a new instance of the <see cref="ShopTable"/> class.
/// </summary>
/// <param name="source">IShopTable to copy the initial values from.</param>
public ShopTable(IShopTable source)
{
CopyValuesFrom(source);
}
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The keys must already exist in the DbParameterValues;
///  this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void CopyValues(this IShopTable source, NetGore.Db.DbParameterValues paramValues)
        {
            paramValues["can_buy"] = (System.Boolean)source.CanBuy;
            paramValues["id"]      = (System.UInt16)source.ID;
            paramValues["name"]    = (System.String)source.Name;
        }
/// <summary>
/// Checks if this <see cref="IShopTable"/> contains the same values as another <see cref="IShopTable"/>.
/// </summary>
/// <param name="source">The source <see cref="IShopTable"/>.</param>
/// <param name="otherItem">The <see cref="IShopTable"/> to compare the values to.</param>
/// <returns>
/// True if this <see cref="IShopTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
/// </returns>
        public static System.Boolean HasSameValues(this IShopTable source, IShopTable otherItem)
        {
            return(Equals(source.CanBuy, otherItem.CanBuy) &&
                   Equals(source.ID, otherItem.ID) &&
                   Equals(source.Name, otherItem.Name));
        }
示例#9
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this ShopTable.
/// </summary>
/// <param name="source">The IShopTable to copy the values from.</param>
        public void CopyValuesFrom(IShopTable source)
        {
            this.CanBuy = (System.Boolean)source.CanBuy;
            this.ID     = (NetGore.Features.Shops.ShopID)source.ID;
            this.Name   = (System.String)source.Name;
        }
示例#10
0
文件: Shop.cs 项目: wtfcolt/game
 /// <summary>
 /// Initializes a new instance of the <see cref="Shop"/> class.
 /// </summary>
 /// <param name="shopTable">The shop table.</param>
 /// <param name="shopItems">The items in the shop.</param>
 public Shop(IShopTable shopTable, IEnumerable <ShopItem> shopItems)
     : base(shopTable.ID, shopTable.Name, shopTable.CanBuy, SortShopItems(shopItems))
 {
 }
示例#11
0
文件: Shop.cs 项目: wtfcolt/game
 /// <summary>
 /// Initializes a new instance of the <see cref="Shop"/> class.
 /// </summary>
 /// <param name="shopTable">The shop table.</param>
 /// <param name="shopItemTables">The shop item tables.</param>
 public Shop(IShopTable shopTable, IEnumerable <IShopItemTable> shopItemTables)
     : this(shopTable, shopItemTables.Select(x => new ShopItem(x)))
 {
 }
示例#12
0
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this ShopTable.
 /// </summary>
 /// <param name="source">The IShopTable to copy the values from.</param>
 public void CopyValuesFrom(IShopTable source)
 {
     CanBuy = source.CanBuy;
     ID = source.ID;
     Name = source.Name;
 }
示例#13
0
 /// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(IShopTable source, IDictionary<String, Object> dic)
 {
     dic["can_buy"] = source.CanBuy;
     dic["id"] = source.ID;
     dic["name"] = source.Name;
 }
示例#14
0
/// <summary>
/// Checks if this <see cref="IShopTable"/> contains the same values as another <see cref="IShopTable"/>.
/// </summary>
/// <param name="source">The source <see cref="IShopTable"/>.</param>
/// <param name="otherItem">The <see cref="IShopTable"/> to compare the values to.</param>
/// <returns>
/// True if this <see cref="IShopTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
/// </returns>
public static System.Boolean HasSameValues(this IShopTable source, IShopTable otherItem)
{
return Equals(source.CanBuy, otherItem.CanBuy) && 
Equals(source.ID, otherItem.ID) && 
Equals(source.Name, otherItem.Name);
}
 /// <summary>
 /// Copies the column values into the given DbParameterValues using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the DbParameterValues;
 ///  this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="paramValues">The DbParameterValues to copy the values into.</param>
 public static void CopyValues(this IShopTable source, DbParameterValues paramValues)
 {
     paramValues["can_buy"] = source.CanBuy;
     paramValues["id"]      = (UInt16)source.ID;
     paramValues["name"]    = source.Name;
 }
示例#16
0
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this ShopTable.
 /// </summary>
 /// <param name="source">The IShopTable to copy the values from.</param>
 public void CopyValuesFrom(IShopTable source)
 {
     CanBuy = source.CanBuy;
     ID     = source.ID;
     Name   = source.Name;
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShopTable"/> class.
 /// </summary>
 /// <param name="source">IShopTable to copy the initial values from.</param>
 public ShopTable(IShopTable source)
 {
     CopyValuesFrom(source);
 }
示例#18
0
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
        public static void CopyValues(IShopTable source, System.Collections.Generic.IDictionary <System.String, System.Object> dic)
        {
            dic["can_buy"] = (System.Boolean)source.CanBuy;
            dic["id"]      = (NetGore.Features.Shops.ShopID)source.ID;
            dic["name"]    = (System.String)source.Name;
        }