/// <summary> /// searches a store for items that have the specified decorations (inexact type match) /// </summary> /// <param name="store"></param> /// <param name="decTypes"></param> /// <returns></returns> public static List <IHasId> SearchForHasDecorations(this ISearchableStore store, params Type[] decTypes) { if (store == null) { return(null); } var filter = LogicOfTo <IHasId, bool> .New((x) => { return(x.HasDecorations(decTypes)); }); var list = store.Search(filter); return(list); }
public static List <T> GetAll <T>(this ISearchableStore store) where T : IHasId { if (store == null) { return(null); } LogicOfTo <IHasId, bool> filter = new LogicOfTo <IHasId, bool>((item) => { if (!(item is T)) { return(false); } return(true); }); var list = store.Search(filter); return(list.ConvertListTo <T, IHasId>()); }
/// <summary> /// filters out non-type items, and those that don't pass the explicit filter /// </summary> public static List <IHasId> SearchOf(this ISearchableStore store, Type type, LogicOfTo <IHasId, bool> filter) { if (store == null) { return(null); } LogicOfTo <IHasId, bool> filter2 = new LogicOfTo <IHasId, bool>((item) => { if (!type.IsAssignableFrom(item.GetType())) { return(false); } LogicOfTo <IHasId, bool> logic = filter.Perform(item) as LogicOfTo <IHasId, bool>; return(logic.Result); }); var list = store.Search(filter2); return(list); }
/// <summary> /// filters out non-T items, and those that don't pass the explicit filter /// </summary> /// <typeparam name="T"></typeparam> /// <param name="store"></param> /// <param name="filter"></param> /// <returns></returns> public static List <T> SearchOf <T>(this ISearchableStore store, LogicOfTo <T, bool> filter) where T : IHasId { if (store == null) { return(null); } LogicOfTo <IHasId, bool> filter2 = new LogicOfTo <IHasId, bool>((item) => { if (!(item is T)) { return(false); } T t = (T)item; LogicOfTo <T, bool> logic = filter.Perform(t) as LogicOfTo <T, bool>; return(logic.Result); }); var list = store.Search(filter2); return(list.ConvertListTo <T, IHasId>()); }