2019-12-24 03:04:26 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Encompass.Exceptions;
|
|
|
|
|
|
|
|
|
|
namespace Encompass
|
|
|
|
|
{
|
|
|
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
|
|
|
public class ReadsImmediate : Attribute
|
|
|
|
|
{
|
2020-03-20 07:09:57 +00:00
|
|
|
|
public readonly HashSet<Type> ReadImmediateTypes = new HashSet<Type>();
|
2019-12-24 03:04:26 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-20 07:09:57 +00:00
|
|
|
|
this.ReadImmediateTypes.Add(readImmediateType);
|
2019-12-24 03:04:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|