encompass-cs/encompass-cs/Attributes/WritesImmediate.cs

28 lines
843 B
C#
Raw Normal View History

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 WritesImmediate : Attribute
{
2020-03-20 07:09:57 +00:00
public readonly HashSet<Type> WriteImmediateTypes = new HashSet<Type>();
2019-12-24 03:04:26 +00:00
public WritesImmediate(params Type[] writeImmediateTypes)
{
foreach (var writeImmediateType in writeImmediateTypes)
{
var isComponent = writeImmediateType.GetInterfaces().Contains(typeof(IComponent));
if (!isComponent)
{
throw new IllegalWriteImmediateTypeException("{0} must be a Component", writeImmediateType.Name);
}
2020-03-20 07:09:57 +00:00
this.WriteImmediateTypes.Add(writeImmediateType);
2019-12-24 03:04:26 +00:00
}
}
}
}