29 lines
805 B
C#
29 lines
805 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Encompass.Exceptions;
|
|
|
|
namespace Encompass
|
|
{
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class ReadsNew : Attribute
|
|
{
|
|
public readonly HashSet<Type> newComponentReadTypes = new HashSet<Type>();
|
|
|
|
public ReadsNew(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.newComponentReadTypes.Add(typeof(ComponentMessage<>).MakeGenericType(readType));
|
|
}
|
|
}
|
|
}
|
|
}
|