Loading files
31473a557This file is pinned to the selected release. Download the original to open it in your design tool.
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.Validation;
namespace Hast.Communication.Services
{
public class CommunicationServiceSelector : ICommunicationServiceSelector
{
private readonly IEnumerable<ICommunicationService> _communicationServices;
public CommunicationServiceSelector(IEnumerable<ICommunicationService> communicationServices)
{
_communicationServices = communicationServices;
}
public ICommunicationService GetCommunicationService(string channelName)
{
Argument.ThrowIfNullOrEmpty(channelName, "channelName");
var communicationService = _communicationServices
.FirstOrDefault(service => service.ChannelName == channelName);
if (communicationService == null)
throw new InvalidOperationException("No communication service was found with the given channel name.");
return communicationService;
}
}
}