28 lines
713 B
C#
28 lines
713 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Encompass.Exceptions;
|
|
|
|
namespace Encompass
|
|
{
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class Sends : Attribute
|
|
{
|
|
public readonly HashSet<Type> sendTypes;
|
|
|
|
public Sends(params Type[] sendTypes)
|
|
{
|
|
foreach (var sendType in sendTypes)
|
|
{
|
|
var isMessage = sendType.GetInterfaces().Contains(typeof(IMessage));
|
|
if (!isMessage)
|
|
{
|
|
throw new IllegalSendTypeException("{0} must be a Message", sendType.Name);
|
|
}
|
|
}
|
|
|
|
this.sendTypes = new HashSet<Type>(sendTypes);
|
|
}
|
|
}
|
|
}
|