using System.Linq;
using InABox.Clients;

namespace InABox.Core
{
    public class PropertyClassLookups : LookupGenerator<object>
    {
        public PropertyClassLookups(object[] items) : base(items)
        {
            var classes = CoreUtils.Entities.Where(x => x.IsSubclassOf(typeof(Entity)) && x.GetInterfaces().Contains(typeof(IPersistent)))
                .OrderBy(x => x.EntityName().Split('.').Last()).ToArray();
            foreach (var entity in classes)
                if (ClientFactory.IsSupported(entity))
                    AddValue(entity.EntityName(), entity.EntityName().Split('.').Last());
        }
    }
}