Actor D.C. Douglas, who played the role of Legion in Mass Effect 2 & 3, has posted an interesting look at the process behind bringing to life a character that doesn't have one set of dialogue, but many.
Given the character's introduction in the last game, and the possibilities inherent for him/it in Mass Effect 3, Douglas had to record three entirely separate dialogue branches depending on the player's reaction and past with Legion. While such things are common for all characters in the game, Legion's are even more bizarre given the fact he can be killed in the second game and then SPOILERS.
Douglas also played the roles of Tactus and the Geth Elder in the game. You can read his piece (which has videos showing his work in the game) at the link below, but be warned, there are some pretty major near-end-game spoilers in parts.
A Mass Effect of Fans [DC Douglas]