2019-07-19 19:47:17 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using Encompass.Exceptions;
|
|
|
|
|
|
|
|
namespace Encompass
|
|
|
|
{
|
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
|
|
public class Receives : Attribute
|
|
|
|
{
|
2020-03-20 07:09:57 +00:00
|
|
|
public readonly HashSet<Type> ReceiveTypes;
|
2019-07-19 19:47:17 +00:00
|
|
|
|
|
|
|
public Receives(params Type[] receiveTypes)
|
|
|
|
{
|
|
|
|
foreach (var receiveType in receiveTypes)
|
|
|
|
{
|
|
|
|
var isMessage = receiveType.GetInterfaces().Contains(typeof(IMessage));
|
|
|
|
if (!isMessage)
|
|
|
|
{
|
|
|
|
throw new IllegalSendTypeException("{0} must be a Message", receiveType.Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-20 07:09:57 +00:00
|
|
|
ReceiveTypes = new HashSet<Type>(receiveTypes);
|
2019-07-19 19:47:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|