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