encompass-cs/encompass-cs/Attributes/Reads.cs

29 lines
731 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(readType);
}
}
}
}