Exemplo n.º 1
0
        public static TSource Single <TSource>(this ReadOnlyMemory <TSource> source, Func <TSource, bool> predicate)
        {
            var aggregate = new SinglePredicate <TSource>(predicate);

            MemoryNode.ProcessMemory(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemplo n.º 2
0
        public static TSource Single <TSource>(this List <TSource> source, Func <TSource, bool> predicate)
        {
            var aggregate = new SinglePredicate <TSource>(predicate);

            ListSegmentNode.ProcessList(source, ref aggregate);
            return(aggregate.GetResult());
        }
Exemplo n.º 3
0
        public static TSource Single <TSource>(this TSource[] source, Func <TSource, bool> predicate)
        {
            var aggregate = new SinglePredicate <TSource>(predicate);

            ArrayNode.ProcessArray(source, ref aggregate);
            return(aggregate.GetResult());
        }
        internal static ChainedPredicate <TItem, SinglePredicate <TItem>, TTailPredicate> Bridge <TItem, TTailPredicate>(Func <TItem, bool> func, string name, ref TTailPredicate tail)
            where TTailPredicate : struct, IStructPredicate <TItem>
        {
            if (func == null)
            {
                throw CommonImplementation.ArgumentNull(name);
            }

            var bridge = new SinglePredicate <TItem>(func);

            return(new ChainedPredicate <TItem, SinglePredicate <TItem>, TTailPredicate>(ref bridge, ref tail));
        }
        internal static ChainedPredicate <TItem, TPredicate, SinglePredicate <TItem> > Bridge <TItem, TPredicate>(ref TPredicate left, Func <TItem, bool> right, string rightName)
            where TPredicate : struct, IStructPredicate <TItem>
        {
            if (right == null)
            {
                throw CommonImplementation.ArgumentNull(rightName);
            }

            var rightBridge = new SinglePredicate <TItem>(right);

            return(new ChainedPredicate <TItem, TPredicate, SinglePredicate <TItem> >(ref left, ref rightBridge));
        }
        internal static ChainedPredicate <TItem, SinglePredicate <TItem>, SinglePredicate <TItem> > Bridge <TItem>(Func <TItem, bool> left, Func <TItem, bool> right, string rightName)
        {
            if (right == null)
            {
                throw CommonImplementation.ArgumentNull(rightName);
            }

            var leftBridge  = new SinglePredicate <TItem>(left);
            var rightBridge = new SinglePredicate <TItem>(right);

            return(new ChainedPredicate <TItem, SinglePredicate <TItem>, SinglePredicate <TItem> >(ref leftBridge, ref rightBridge));
        }