encompass-cs/encompass-cs/Attributes/Sends.cs

28 lines
713 B
C#
Raw Normal View History

2019-07-19 01:20:38 +00:00
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)
{
2019-07-19 19:47:17 +00:00
throw new IllegalSendTypeException("{0} must be a Message", sendType.Name);
2019-07-19 01:20:38 +00:00
}
}
this.sendTypes = new HashSet<Type>(sendTypes);
}
}
}