encompass-cs/encompass-cs/Attributes/WritesPending.cs

26 lines
772 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Encompass.Exceptions;
namespace Encompass
{
public class WritesPending : Attribute
{
public readonly HashSet<Type> writePendingTypes = new HashSet<Type>();
public WritesPending(params Type[] writePendingTypes)
{
foreach (var writePendingType in writePendingTypes)
{
var isComponent = writePendingType.GetInterfaces().Contains(typeof(IComponent));
if (!isComponent)
{
throw new IllegalWritePendingTypeException("{0} must be a Component", writePendingType.Name);
}
this.writePendingTypes.Add(writePendingType);
}
}
}
}