Beispiel #1
0
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
        public static void TryReadValues(this QuestTable source, System.Data.IDataRecord dataRecord)
        {
            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "id":
                    source.ID = (NetGore.Features.Quests.QuestID)(NetGore.Features.Quests.QuestID) dataRecord.GetUInt16(i);
                    break;


                case "repeatable":
                    source.Repeatable = (System.Boolean)(System.Boolean) dataRecord.GetBoolean(i);
                    break;


                case "reward_cash":
                    source.RewardCash = (System.Int32)(System.Int32) dataRecord.GetInt32(i);
                    break;


                case "reward_exp":
                    source.RewardExp = (System.Int32)(System.Int32) dataRecord.GetInt32(i);
                    break;
                }
            }
        }
/// <summary>
/// Reads the values from an <see cref="IDataRecord"/> and assigns the read values to this
/// object's properties. The database column's name is used to as the key, so the value
/// will not be found if any aliases are used or not all columns were selected.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataRecord"/> to read the values from. Must already be ready to be read from.</param>
        public static void ReadValues(this AccountBanTable source, System.Data.IDataRecord dataRecord)
        {
            System.Int32 i;

            i = dataRecord.GetOrdinal("account_id");

            source.AccountID = (DemoGame.AccountID)(DemoGame.AccountID) dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("end_time");

            source.EndTime = (System.DateTime)(System.DateTime) dataRecord.GetDateTime(i);

            i = dataRecord.GetOrdinal("expired");

            source.Expired = (System.Boolean)(System.Boolean) dataRecord.GetBoolean(i);

            i = dataRecord.GetOrdinal("id");

            source.ID = (System.Int32)(System.Int32) dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("issued_by");

            source.IssuedBy = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("reason");

            source.Reason = (System.String)(System.String) dataRecord.GetString(i);

            i = dataRecord.GetOrdinal("start_time");

            source.StartTime = (System.DateTime)(System.DateTime) dataRecord.GetDateTime(i);
        }
/// <summary>
/// Reads the values from an <see cref="IDataRecord"/> and assigns the read values to this
/// object's properties. The database column's name is used to as the key, so the value
/// will not be found if any aliases are used or not all columns were selected.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataRecord"/> to read the values from. Must already be ready to be read from.</param>
        public static void ReadValues(this ShopTable source, System.Data.IDataRecord dataRecord)
        {
            System.Int32 i;

            i = dataRecord.GetOrdinal("can_buy");

            source.CanBuy = (System.Boolean)(System.Boolean) dataRecord.GetBoolean(i);

            i = dataRecord.GetOrdinal("id");

            source.ID = (NetGore.Features.Shops.ShopID)(NetGore.Features.Shops.ShopID) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("name");

            source.Name = (System.String)(System.String) dataRecord.GetString(i);
        }
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
        public static void TryReadValues(this AccountBanTable source, System.Data.IDataRecord dataRecord)
        {
            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "account_id":
                    source.AccountID = (DemoGame.AccountID)(DemoGame.AccountID) dataRecord.GetInt32(i);
                    break;


                case "end_time":
                    source.EndTime = (System.DateTime)(System.DateTime) dataRecord.GetDateTime(i);
                    break;


                case "expired":
                    source.Expired = (System.Boolean)(System.Boolean) dataRecord.GetBoolean(i);
                    break;


                case "id":
                    source.ID = (System.Int32)(System.Int32) dataRecord.GetInt32(i);
                    break;


                case "issued_by":
                    source.IssuedBy = (System.String)(System.String)(dataRecord.IsDBNull(i) ? (System.String)null : dataRecord.GetString(i));
                    break;


                case "reason":
                    source.Reason = (System.String)(System.String) dataRecord.GetString(i);
                    break;


                case "start_time":
                    source.StartTime = (System.DateTime)(System.DateTime) dataRecord.GetDateTime(i);
                    break;
                }
            }
        }
Beispiel #5
0
/// <summary>
/// Reads the values from an <see cref="IDataRecord"/> and assigns the read values to this
/// object's properties. The database column's name is used to as the key, so the value
/// will not be found if any aliases are used or not all columns were selected.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataRecord"/> to read the values from. Must already be ready to be read from.</param>
        public static void ReadValues(this QuestTable source, System.Data.IDataRecord dataRecord)
        {
            System.Int32 i;

            i = dataRecord.GetOrdinal("id");

            source.ID = (NetGore.Features.Quests.QuestID)(NetGore.Features.Quests.QuestID) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("repeatable");

            source.Repeatable = (System.Boolean)(System.Boolean) dataRecord.GetBoolean(i);

            i = dataRecord.GetOrdinal("reward_cash");

            source.RewardCash = (System.Int32)(System.Int32) dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("reward_exp");

            source.RewardExp = (System.Int32)(System.Int32) dataRecord.GetInt32(i);
        }
/// <summary>
/// Reads the values from an <see cref="IDataReader"/> and assigns the read values to this
/// object's properties. Unlike ReadValues(), this method not only doesn't require
/// all values to be in the <see cref="IDataReader"/>, but also does not require the values in
/// the <see cref="IDataReader"/> to be a defined field for the table this class represents.
/// Because of this, you need to be careful when using this method because values
/// can easily be skipped without any indication.
/// </summary>
/// <param name="source">The object to add the extension method to.</param>
/// <param name="dataRecord">The <see cref="IDataReader"/> to read the values from. Must already be ready to be read from.</param>
        public static void TryReadValues(this ShopTable source, System.Data.IDataRecord dataRecord)
        {
            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "can_buy":
                    source.CanBuy = (System.Boolean)(System.Boolean) dataRecord.GetBoolean(i);
                    break;


                case "id":
                    source.ID = (NetGore.Features.Shops.ShopID)(NetGore.Features.Shops.ShopID) dataRecord.GetUInt16(i);
                    break;


                case "name":
                    source.Name = (System.String)(System.String) dataRecord.GetString(i);
                    break;
                }
            }
        }