using System; using System.Collections.Generic; using System.Linq; using Encompass.Exceptions; namespace Encompass { [AttributeUsage(AttributeTargets.Class)] public class Reads : Attribute { public readonly HashSet readTypes = new HashSet(); public Reads(params Type[] readTypes) { foreach (var readType in readTypes) { var isComponent = readType.GetInterfaces().Contains(typeof(IComponent)); if (!isComponent) { throw new IllegalReadTypeException("{0} must be a Component", readType.Name); } this.readTypes.Add(typeof(ComponentMessage<>).MakeGenericType(readType)); } } } }