Beispiel #1
0
        /// <summary>
        /// Adds a condition for future loads
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"/>
        public Gatherer WithCondition(GatherCondition condition)
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

            conditions.Add(condition);
            return(this);
        }
Beispiel #2
0
        /// <summary>
        /// Loads only types that are of <typeparamref name="T"/>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public IEnumerable <Harvest> LoadOnly <T>()
        {
            var typeCondition = new GatherCondition("Type " + typeof(T).Name, (x) => x.GetInterfaces().Contains(typeof(T)));

            conditions.Add(typeCondition);

            var pluginTypes = LoadAll();

            conditions.Remove(typeCondition);

            return(pluginTypes);
        }
Beispiel #3
0
        /// <summary>
        /// Removes a condition from being checked from further loads
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"/>
        public Gatherer WithoutCondition(GatherCondition condition)
        {
            if (condition == null)
            {
                throw new ArgumentNullException(nameof(condition));
            }

            if (conditions.Contains(condition))
            {
                conditions.Remove(condition);
            }

            return(this);
        }