You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
5 years ago
|
// Needed for NET30
|
||
|
#if !NET_4_6
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
using LinqInternal.Core;
|
||
|
|
||
|
namespace LinqInternal.Collections.Specialized
|
||
|
{
|
||
|
[System.Diagnostics.DebuggerNonUserCode]
|
||
|
internal sealed class ConditionalExtendedEnumerable<T> : ExtendedEnumerableBase<T>, IEnumerable<T>
|
||
|
{
|
||
|
private readonly Func<bool> _enumerateAppend;
|
||
|
private readonly Func<bool> _enumerateTarget;
|
||
|
|
||
|
public ConditionalExtendedEnumerable(IEnumerable<T> target, IEnumerable<T> append, Func<bool> enumerateTarget, Func<bool> enumerateAppend)
|
||
|
: base(target, append)
|
||
|
{
|
||
|
if (enumerateTarget == null)
|
||
|
{
|
||
|
throw new ArgumentNullException("enumerateTarget");
|
||
|
}
|
||
|
_enumerateTarget = enumerateTarget;
|
||
|
_enumerateAppend = enumerateAppend ?? (null == append ? FuncHelper.GetFallacyFunc() : FuncHelper.GetTautologyFunc());
|
||
|
}
|
||
|
|
||
|
public override IEnumerator<T> GetEnumerator()
|
||
|
{
|
||
|
if (_enumerateTarget.Invoke())
|
||
|
{
|
||
|
foreach (var item in Target)
|
||
|
{
|
||
|
yield return item;
|
||
|
}
|
||
|
}
|
||
|
if (_enumerateAppend.Invoke())
|
||
|
{
|
||
|
foreach (var item in Append)
|
||
|
{
|
||
|
yield return item;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endif
|