/// <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 ItemTemplateTable source, System.Data.IDataRecord dataRecord)
        {
            System.Int32 i;

            i = dataRecord.GetOrdinal("action_display_id");

            source.ActionDisplayID = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.UInt16>)null : dataRecord.GetUInt16(i));

            i = dataRecord.GetOrdinal("description");

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

            i = dataRecord.GetOrdinal("equipped_body");

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

            i = dataRecord.GetOrdinal("graphic");

            source.Graphic = (NetGore.GrhIndex)(NetGore.GrhIndex) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("height");

            source.Height = (System.Byte)(System.Byte) dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("hp");

            source.HP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("id");

            source.ID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("mp");

            source.MP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("name");

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

            i = dataRecord.GetOrdinal("range");

            source.Range = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("stat_agi");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_defence");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_int");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhit");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhp");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxmp");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_minhit");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_agi");

            source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_int");

            source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_str");

            source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_str");

            source.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("type");

            source.Type = (DemoGame.ItemType)(DemoGame.ItemType) dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("value");

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

            i = dataRecord.GetOrdinal("weapon_type");

            source.WeaponType = (DemoGame.WeaponType)(DemoGame.WeaponType) dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("width");

            source.Width = (System.Byte)(System.Byte) dataRecord.GetByte(i);
        }
示例#2
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 ItemTemplateTable source, IDataRecord dataRecord)
        {
            for (var i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "action_display_id":
                    source.ActionDisplayID =
                        (Nullable <ActionDisplayID>)(dataRecord.IsDBNull(i) ? (ushort?)null : dataRecord.GetUInt16(i));
                    break;

                case "description":
                    source.Description = dataRecord.GetString(i);
                    break;

                case "equipped_body":
                    source.EquippedBody = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));
                    break;

                case "graphic":
                    source.Graphic = (GrhIndex)dataRecord.GetUInt16(i);
                    break;

                case "height":
                    source.Height = dataRecord.GetByte(i);
                    break;

                case "hp":
                    source.HP = dataRecord.GetInt16(i);
                    break;

                case "id":
                    source.ID = (ItemTemplateID)dataRecord.GetUInt16(i);
                    break;

                case "mp":
                    source.MP = dataRecord.GetInt16(i);
                    break;

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

                case "range":
                    source.Range = dataRecord.GetUInt16(i);
                    break;

                case "stat_agi":
                    source.SetStat(StatType.Agi, dataRecord.GetInt16(i));
                    break;

                case "stat_defence":
                    source.SetStat(StatType.Defence, dataRecord.GetInt16(i));
                    break;

                case "stat_int":
                    source.SetStat(StatType.Int, dataRecord.GetInt16(i));
                    break;

                case "stat_maxhit":
                    source.SetStat(StatType.MaxHit, dataRecord.GetInt16(i));
                    break;

                case "stat_maxhp":
                    source.SetStat(StatType.MaxHP, dataRecord.GetInt16(i));
                    break;

                case "stat_maxmp":
                    source.SetStat(StatType.MaxMP, dataRecord.GetInt16(i));
                    break;

                case "stat_minhit":
                    source.SetStat(StatType.MinHit, dataRecord.GetInt16(i));
                    break;

                case "stat_req_agi":
                    source.SetReqStat(StatType.Agi, dataRecord.GetInt16(i));
                    break;

                case "stat_req_int":
                    source.SetReqStat(StatType.Int, dataRecord.GetInt16(i));
                    break;

                case "stat_req_str":
                    source.SetReqStat(StatType.Str, dataRecord.GetInt16(i));
                    break;

                case "stat_str":
                    source.SetStat(StatType.Str, dataRecord.GetInt16(i));
                    break;

                case "type":
                    source.Type = (ItemType)dataRecord.GetByte(i);
                    break;

                case "value":
                    source.Value = dataRecord.GetInt32(i);
                    break;

                case "weapon_type":
                    source.WeaponType = (WeaponType)dataRecord.GetByte(i);
                    break;

                case "width":
                    source.Width = dataRecord.GetByte(i);
                    break;
                }
            }
        }
/// <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 ItemTemplateTable source, System.Data.IDataRecord dataRecord)
        {
            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                switch (dataRecord.GetName(i))
                {
                case "action_display_id":
                    source.ActionDisplayID = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)(dataRecord.IsDBNull(i) ? (System.Nullable <System.UInt16>)null : dataRecord.GetUInt16(i));
                    break;


                case "description":
                    source.Description = (System.String)(System.String) dataRecord.GetString(i);
                    break;


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


                case "graphic":
                    source.Graphic = (NetGore.GrhIndex)(NetGore.GrhIndex) dataRecord.GetUInt16(i);
                    break;


                case "height":
                    source.Height = (System.Byte)(System.Byte) dataRecord.GetByte(i);
                    break;


                case "hp":
                    source.HP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);
                    break;


                case "id":
                    source.ID = (DemoGame.ItemTemplateID)(DemoGame.ItemTemplateID) dataRecord.GetUInt16(i);
                    break;


                case "mp":
                    source.MP = (DemoGame.SPValueType)(DemoGame.SPValueType) dataRecord.GetInt16(i);
                    break;


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


                case "range":
                    source.Range = (System.UInt16)(System.UInt16) dataRecord.GetUInt16(i);
                    break;


                case "stat_agi":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_defence":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_int":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_maxhit":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_maxhp":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_maxmp":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_minhit":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_req_agi":
                    source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_req_int":
                    source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_req_str":
                    source.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "stat_str":
                    source.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)(System.Int16) dataRecord.GetInt16(i));
                    break;


                case "type":
                    source.Type = (DemoGame.ItemType)(DemoGame.ItemType) dataRecord.GetByte(i);
                    break;


                case "value":
                    source.Value = (System.Int32)(System.Int32) dataRecord.GetInt32(i);
                    break;


                case "weapon_type":
                    source.WeaponType = (DemoGame.WeaponType)(DemoGame.WeaponType) dataRecord.GetByte(i);
                    break;


                case "width":
                    source.Width = (System.Byte)(System.Byte) dataRecord.GetByte(i);
                    break;
                }
            }
        }
示例#4
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 ItemTemplateTable source, IDataRecord dataRecord)
        {
            Int32 i;

            i = dataRecord.GetOrdinal("action_display_id");

            source.ActionDisplayID = (Nullable <ActionDisplayID>)(dataRecord.IsDBNull(i) ? (ushort?)null : dataRecord.GetUInt16(i));

            i = dataRecord.GetOrdinal("description");

            source.Description = dataRecord.GetString(i);

            i = dataRecord.GetOrdinal("equipped_body");

            source.EquippedBody = (dataRecord.IsDBNull(i) ? null : dataRecord.GetString(i));

            i = dataRecord.GetOrdinal("graphic");

            source.Graphic = (GrhIndex)dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("height");

            source.Height = dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("hp");

            source.HP = dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("id");

            source.ID = (ItemTemplateID)dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("mp");

            source.MP = dataRecord.GetInt16(i);

            i = dataRecord.GetOrdinal("name");

            source.Name = dataRecord.GetString(i);

            i = dataRecord.GetOrdinal("range");

            source.Range = dataRecord.GetUInt16(i);

            i = dataRecord.GetOrdinal("stat_agi");

            source.SetStat(StatType.Agi, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_defence");

            source.SetStat(StatType.Defence, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_int");

            source.SetStat(StatType.Int, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhit");

            source.SetStat(StatType.MaxHit, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxhp");

            source.SetStat(StatType.MaxHP, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_maxmp");

            source.SetStat(StatType.MaxMP, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_minhit");

            source.SetStat(StatType.MinHit, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_agi");

            source.SetReqStat(StatType.Agi, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_int");

            source.SetReqStat(StatType.Int, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_req_str");

            source.SetReqStat(StatType.Str, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("stat_str");

            source.SetStat(StatType.Str, dataRecord.GetInt16(i));

            i = dataRecord.GetOrdinal("type");

            source.Type = (ItemType)dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("value");

            source.Value = dataRecord.GetInt32(i);

            i = dataRecord.GetOrdinal("weapon_type");

            source.WeaponType = (WeaponType)dataRecord.GetByte(i);

            i = dataRecord.GetOrdinal("width");

            source.Width = dataRecord.GetByte(i);
        }