27 lines
801 B
C#
27 lines
801 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Encompass.Exceptions;
|
|
|
|
namespace Encompass
|
|
{
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public class Updates : Attribute
|
|
{
|
|
public readonly HashSet<Type> updateTypes = new HashSet<Type>();
|
|
|
|
public Updates(params Type[] updateTypes)
|
|
{
|
|
foreach (var updateType in updateTypes)
|
|
{
|
|
var isComponent = updateType.GetInterfaces().Contains(typeof(IComponent));
|
|
if (!isComponent)
|
|
{
|
|
throw new IllegalUpdateTypeException("{0} must be a Component", updateType.Name);
|
|
}
|
|
|
|
this.updateTypes.Add(typeof(ComponentUpdateMessage<>).MakeGenericType(updateType));
|
|
}
|
|
}
|
|
}
|
|
} |