Ejemplo n.º 1
0
        /// <summary>
        /// performs a regular GetAll of T, where T is IHasDependencyOf THasA, sorted by the Dependency
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="THasA"></typeparam>
        /// <param name="store"></param>
        public static List <T> GetAllHasADependency <T, THasA>(this ISearchableStore store)
            where T : IHasId, IHasDependencyOf <THasA>
        {
            if (store == null)
            {
                return(null);
            }

            var list = store.GetAll <T>();

            List <IHasDependencyOf <THasA> > depList = new List <IHasDependencyOf <THasA> >();

            list.WithEach(x =>
            {
                depList.Add(x);
            });

            //sort deplist
            depList = DependencyUtil.SortHasADependencies(depList);


            //convert to T
            List <T> returnValue = new List <T>();

            depList.WithEach(x =>
            {
                returnValue.Add((T)x);
            });

            return(returnValue);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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>());
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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>());
        }