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