private Boolean addAlias(String aliasName, ref CharacterAlias ca) { ca = new CharacterAlias(); ca.Name = aliasName; ca.AliasId = NextAliasIndex++; //Don't have the extended properties available from TMDB return(CharacterAliases.Add(ca)); //Try to add to CharacterAliases }
/// <summary> /// Function to split names into aliases /// </summary> /// <param name="characterName"></param> private HashSet <CharacterAlias> findOrAddAliases(String characterName, String newCharacterName) { HashSet <CharacterAlias> retVal = new HashSet <CharacterAlias>(); // Default to empty set. //Name = characterName; String[] substrings = getSplitName(characterName, '~'); if (substrings.Count() > 1) { foreach (String item in substrings) { string aliasName = item.Trim(); // Trim before Lookup //Find Exact Match on Alias by Name Only CharacterAlias ca = CharacterAliases.FirstOrDefault(o => o.Name == aliasName); bool success = false; if (ca == null) { if (aliasName != newCharacterName) { ca = new CharacterAlias(); ca.Name = aliasName; ca.AliasId = NextAliasIndex++; success = addAlias(aliasName, ref ca); //Try to add to CharacterAliases if (success) { retVal.Add(ca); } } } else { retVal.Add(ca); } //if (success) //{ // retVal.Add(ca); //} //else //{ // Console.WriteLine("Debug!! findOrAddAliases: " + ca.Name + " failed to be added to CharacterAliases"); //} } } else { //At least part of this is needed to match "Rhodey Rodes" to full name CharacterAlias ca = CharacterAliases.FirstOrDefault(o => o.Name == characterName); bool success = false; if (ca == null) { ca = new CharacterAlias(); ca.Name = characterName; ca.AliasId = NextAliasIndex++; //success = addAlias(characterName, ref ca); //Try to add to CharacterAliases (Creates an Alias for a single character and that is not desired.) success = true; //Debug - Seems to work for War Machine. } else { success = true; } if (success) { retVal.Add(ca); } else { Console.WriteLine("Debug!! findOrAddAliases: " + ca.Name + " failed to be added to CharacterAliases"); } } return(retVal); }