28 lines
743 B
C#
28 lines
743 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Encompass.Exceptions;
|
|
|
|
namespace Encompass
|
|
{
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class Receives : Attribute
|
|
{
|
|
public readonly HashSet<Type> receiveTypes;
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
this.receiveTypes = new HashSet<Type>(receiveTypes);
|
|
}
|
|
}
|
|
}
|