encompass-cs/encompass-cs/Attributes/ReadsPending.cs

28 lines
800 B
C#
Raw Normal View History

2019-07-23 17:17:53 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using Encompass.Exceptions;
namespace Encompass
{
[AttributeUsage(AttributeTargets.Class)]
public class ReadsPending : Attribute
{
public readonly HashSet<Type> readPendingTypes = new HashSet<Type>();
public ReadsPending(params Type[] readPendingTypes)
{
foreach (var readPendingType in readPendingTypes)
{
var isComponent = readPendingType.GetInterfaces().Contains(typeof(IComponent));
if (!isComponent)
{
throw new IllegalReadTypeException("{0} must be a Component", readPendingType.Name);
}
2019-12-06 03:55:17 +00:00
this.readPendingTypes.Add(readPendingType);
2019-07-23 17:17:53 +00:00
}
}
}
}