private void ProcessPortfolioMessage(string portfolioName, Message message) { var adapter = portfolioName.IsEmpty() ? null : AdapterProvider.GetAdapter(portfolioName); if (adapter == null) { var adapters = _messageTypeAdapters.TryGetValue(message.Type)?.Cache; if (adapters == null || adapters.Length != 1) { throw new InvalidOperationException(LocalizedStrings.Str623Params.Put(portfolioName)); } adapter = adapters.First(); } else { var a = _hearbeatAdapters.TryGetValue(adapter); if (a == null) { throw new InvalidOperationException(LocalizedStrings.Str1838Params.Put(adapter.GetType())); } adapter = a; } adapter.SendInMessage(message); }