/// <summary> /// Clones the specified LST CharacterArmor. /// </summary> /// <param name="lstCharacterArmor">The LST CharacterArmor.</param> /// <returns>List<CharacterArmor></returns> static public List <CharacterArmor> Clone(List <CharacterArmor> lstCharacterArmor) { List <CharacterArmor> lstCCharacterArmor = new List <CharacterArmor>(); foreach (CharacterArmor objCharacterArmor in lstCharacterArmor) { lstCCharacterArmor.Add(CharacterArmor.Clone(objCharacterArmor)); } return(lstCCharacterArmor); }
static public List <CharacterArmor> RemoveCharacterArmorFromList(CharacterArmor objCharacterArmor, List <CharacterArmor> lstCharArmors) { List <CharacterArmor> retList = new List <CharacterArmor>(); foreach (CharacterArmor objCharAromr in lstCharArmors) { if (objCharacterArmor.CharacterArmorID != objCharAromr.CharacterArmorID) { retList.Add(objCharAromr); } } return(retList); }
private void SetReaderToObject(ref CharacterArmor objCharacterArmor, ref SqlDataReader result) { if (result.HasRows) { objCharacterArmor.CharacterArmorID = (int)result.GetValue(result.GetOrdinal("CharacterArmorID")); objCharacterArmor.CharacterID = (int)result.GetValue(result.GetOrdinal("CharacterID")); objCharacterArmor.ArmorID = (int)result.GetValue(result.GetOrdinal("ArmorID")); objCharacterArmor.Worn = (bool)result.GetValue(result.GetOrdinal("Worn")); objCharacterArmor.Notes = result.GetValue(result.GetOrdinal("Notes")).ToString(); objCharacterArmor.objArmor = new Armor(objCharacterArmor.ArmorID); Modification objModification = new Modification(); objCharacterArmor.lstModifications = objModification.GetCharacterArmorModifications(objCharacterArmor.CharacterArmorID); } }
/// <summary> /// Clones the specified object CharacterArmor. /// </summary> /// <param name="objCharacterArmor">The object CharacterArmor.</param> /// <returns>CharacterArmor</returns> static public CharacterArmor Clone(CharacterArmor objCharacterArmor, bool blnFromDatabase = false) { //Get the data from the database(?) then match it with what is passed in, we want to clone what is passed in for Character Items, not List Items CharacterArmor objCCharacterArmor = new CharacterArmor(); if (blnFromDatabase) { objCCharacterArmor.GetCharacterArmor(objCharacterArmor.CharacterID, objCharacterArmor.ArmorID); } else { objCCharacterArmor.CharacterArmorID = objCharacterArmor.CharacterArmorID; objCCharacterArmor.CharacterID = objCharacterArmor.CharacterID; objCCharacterArmor.ArmorID = objCharacterArmor.ArmorID; objCCharacterArmor.Worn = objCharacterArmor.Worn; objCCharacterArmor.Notes = objCharacterArmor.Notes; objCCharacterArmor.objArmor = Armor.Clone(objCharacterArmor.objArmor); objCCharacterArmor.lstModifications = Modification.Clone(objCharacterArmor.lstModifications); } return(objCCharacterArmor); }
private List <CharacterArmor> GetCharacterArmorList(string strSprocName, string strWhere, string strOrderBy) { List <CharacterArmor> CharacterArmors = new List <CharacterArmor>(); SqlDataReader result; DatabaseConnection dbconn = new DatabaseConnection(); SqlCommand command = new SqlCommand(); SqlConnection connection = new SqlConnection(dbconn.SQLSEVERConnString); try { connection.Open(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = strSprocName; command.Parameters.Add(dbconn.GenerateParameterObj("@strWhere", SqlDbType.VarChar, strWhere, 1000)); command.Parameters.Add(dbconn.GenerateParameterObj("@strOrderBy", SqlDbType.VarChar, strOrderBy, 1000)); result = command.ExecuteReader(); while (result.Read()) { CharacterArmor objCharacterArmor = new CharacterArmor(); SetReaderToObject(ref objCharacterArmor, ref result); CharacterArmors.Add(objCharacterArmor); } } catch { Exception e = new Exception(); throw e; } finally { command.Dispose(); connection.Close(); } return(CharacterArmors); }