public RiotAccount Attach(AccountConfig config) { RiotAccount riotAccount = Enumerable.FirstOrDefault<RiotAccount>((IEnumerable<RiotAccount>) this.accounts, (Func<RiotAccount, bool>) (x => { if (x.Username == config.Username) return x.RealmId == config.RealmId; else return false; })); if (riotAccount != null) return riotAccount; RiotAccount account = new RiotAccount(config) { CanConnect = true }; account.ConnectAsync(); this.accounts.Add(account); this.OnAccountAdded(account); return account; }
public RiotAccount Attach(AccountConfig config) { RiotAccount riotAccount = this.accounts.FirstOrDefault<RiotAccount>((RiotAccount x) => { if (x.Username != config.Username) { return false; } return x.RealmId == config.RealmId; }); if (riotAccount != null) { return riotAccount; } RiotAccount riotAccount1 = new RiotAccount(config) { CanConnect = true }; riotAccount1.ConnectAsync(); this.accounts.Add(riotAccount1); this.OnAccountAdded(riotAccount1); return riotAccount1; }