/*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Creates a terminating condition that determines whether any items in the series match the predicate.
        /// </summary>
        /// <param name="predicate">The predicate to execute.</param>
        public TerminatingCondition <TRoot, TSubject> Has(Predicate <TItem> predicate)
        {
#if !MONO
            return(Terminate(e => e.Has(predicate)));
#else
            return(Terminate(e => ExtensionsForIEnumerable.Has(e, predicate)));
#endif
        }
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Continues the conditional chain by counting the number of items in the collection that match
        /// the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate to execute.</param>
        public Int32ConditionBuilder <TRoot, TSubject> CountMatches(Predicate <TItem> predicate)
        {
#if !MONO
            return(new Int32ConditionBuilder <TRoot, TSubject>(this, e => e.Count(predicate)));
#else
            return(new Int32ConditionBuilder <TRoot, TSubject>(this, e => ExtensionsForIEnumerable.Count(e, predicate)));
#endif
        }
        /*----------------------------------------------------------------------------------------*/
        #region Public Methods
        /// <summary>
        /// Loads the module into the kernel.
        /// </summary>
        public override void Load()
        {
#if !MONO
            _assemblies.Each(RegisterControllers);
#else
            ExtensionsForIEnumerable.Each(_assemblies, RegisterControllers);
#endif
        }
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Initializes a new instance of the <see cref="AutoControllerModule"/> class.
        /// </summary>
        /// <param name="assemblyNames">The names of assemblies which should be scanned for controllers.</param>
        public AutoControllerModule(params string[] assemblyNames)
        {
#if !MONO
            _assemblies = assemblyNames.Convert(s => Assembly.Load(s));
#else
            _assemblies = ExtensionsForIEnumerable.Convert(assemblyNames, s => Assembly.Load(s));
#endif
        }
        public void ToListSlow_Large()
        {
            var list = ExtensionsForIEnumerable.ToListSlow(_largeEnumerable, typeof(string));

            foreach (var item in list)
            {
                if (item == null)
                {
                    throw new Exception();
                }
            }
        }
Beispiel #6
0
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Returns a value indicating whether the specified member should be injected during activation.
        /// </summary>
        /// <param name="binding">The binding that points at the type whose activation plan being manipulated.</param>
        /// <param name="plan">The activation plan that is being manipulated.</param>
        /// <param name="candidates">The candidates that are available.</param>
        /// <param name="member">The member in question.</param>
        /// <returns><see langword="True"/> if the member should be injected, otherwise <see langword="false"/>.</returns>
        public bool ShouldInject(IBinding binding, IActivationPlan plan, IEnumerable <MethodInfo> candidates, MethodInfo member)
        {
            var registry = binding.Components.BindingRegistry;

            ParameterInfo[] parameters = member.GetParameters();
#if !MONO
            return(parameters.Length > 0 && parameters.Convert(p => p.ParameterType).All(registry.HasBinding));
#else
            return(parameters.Length > 0 &&
                   ExtensionsForIEnumerable.All(
                       ExtensionsForIEnumerable.Convert(parameters, p => p.ParameterType),
                       registry.HasBinding));
#endif
        }
Beispiel #7
0
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Returns a value indicating whether the specified member should be injected during activation.
        /// </summary>
        /// <param name="binding">The binding that points at the type whose activation plan being manipulated.</param>
        /// <param name="plan">The activation plan that is being manipulated.</param>
        /// <param name="candidates">The candidates that are available.</param>
        /// <param name="member">The member in question.</param>
        /// <returns>
        ///     <see langword="True"/> if the member should be injected, otherwise <see langword="false"/>.
        /// </returns>
        public bool ShouldInject(IBinding binding, IActivationPlan plan, IEnumerable <ConstructorInfo> candidates, ConstructorInfo member)
        {
#if !MONO
            var list = candidates.ToList();
#else
            var list = ExtensionsForIEnumerable.ToList(candidates);
#endif

            if (list.Count == 1)
            {
                return(true);
            }

            var registry = binding.Components.BindingRegistry;
#if !MONO
            return(member == candidates.Best(c => c.GetParameterTypes().Count(registry.HasBinding)));
#else
            return(member == ExtensionsForIEnumerable
                   .Best(candidates,
                         c =>
                         ExtensionsForIEnumerable.Count(ExtensionsForMethodBase.GetParameterTypes(c), registry.HasBinding)));
#endif
        }
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Continues the conditional chain, examining only items in the series that match the specified predicate.
        /// </summary>
        /// <param name="predicate">The predicate to execute.</param>
        public EnumerableConditionBuilder <TRoot, TSubject, IEnumerable <TItem>, TItem> Where(Predicate <TItem> predicate)
        {
#if !MONO
            return(new EnumerableConditionBuilder <TRoot, TSubject, IEnumerable <TItem>, TItem>(this, e => e.Where(predicate)));
#else
            return(new EnumerableConditionBuilder <TRoot, TSubject, IEnumerable <TItem>, TItem>(this, e => ExtensionsForIEnumerable.Where(e, predicate)));
#endif
        }
        /*----------------------------------------------------------------------------------------*/
        #region EDSL Members
        /// <summary>
        /// Continues the conditional chain, converting all items in the input series.
        /// </summary>
        /// <typeparam name="TOutput">The type of item to convert to.</typeparam>
        /// <param name="converter">The converter callback to execute.</param>
        public EnumerableConditionBuilder <TRoot, TSubject, IEnumerable <TOutput>, TOutput> Convert <TOutput>(Func <TItem, TOutput> converter)
        {
#if !MONO
            return(new EnumerableConditionBuilder <TRoot, TSubject, IEnumerable <TOutput>, TOutput>(this, e => e.Convert(converter)));
#else
            return(new EnumerableConditionBuilder <TRoot, TSubject, IEnumerable <TOutput>, TOutput>(this, e => ExtensionsForIEnumerable.Convert(e, converter)));
#endif
        }