28 lines
843 B
C#
28 lines
843 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using Encompass.Exceptions;
|
|||
|
|
|||
|
namespace Encompass
|
|||
|
{
|
|||
|
[AttributeUsage(AttributeTargets.Class)]
|
|||
|
public class WritesImmediate : Attribute
|
|||
|
{
|
|||
|
public readonly HashSet<Type> writeImmediateTypes = new HashSet<Type>();
|
|||
|
|
|||
|
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);
|
|||
|
}
|
|||
|
|
|||
|
this.writeImmediateTypes.Add(writeImmediateType);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|