29 lines
824 B
C#
29 lines
824 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Encompass.Exceptions;
|
|
|
|
namespace Encompass
|
|
{
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class ReadsImmediate : Attribute
|
|
{
|
|
public readonly HashSet<Type> readImmediateTypes = new HashSet<Type>();
|
|
|
|
public ReadsImmediate(params Type[] readImmediateTypes)
|
|
{
|
|
foreach (var readImmediateType in readImmediateTypes)
|
|
{
|
|
var isComponent = readImmediateType.GetInterfaces().Contains(typeof(IComponent));
|
|
|
|
if (!isComponent)
|
|
{
|
|
throw new IllegalReadTypeException("{0} must be a Component", readImmediateType.Name);
|
|
}
|
|
|
|
this.readImmediateTypes.Add(readImmediateType);
|
|
}
|
|
}
|
|
}
|
|
}
|