<PackageReference Include="System.Reactive" Version="6.1.0-preview.9" />
    
    
	
	
		
		
		
	 
	
	
        
                
                DefaultIfEmpty<TSource>
                
                
                
                
using System.
Runtime.
CompilerServices;
namespace System.
Reactive.
Linq.
ObservableImpl
{
    [
System.
Runtime.
CompilerServices.
NullableContext(
1)]
    [
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
        
0,
        
1,
        
1,
        
1
    })]
    
internal sealed class DefaultIfEmpty<[
System.
Runtime.
CompilerServices.
Nullable(
2)] 
TSource> : 
Producer<
TSource, 
DefaultIfEmpty<
TSource>.
_>
    {
        [
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
            
0,
            
1
        })]
        
internal sealed class _ : 
IdentitySink<
TSource>
        {
            
private readonly TSource _defaultValue;
            
private bool _found;
            
public _(
TSource defaultValue, 
IObserver<
TSource> 
observer)
                : 
base(
observer)
            {
                
_defaultValue = 
defaultValue;
                
_found = 
false;
            }
            
public override void OnNext(
TSource value)
            {
                
_found = 
true;
                
ForwardOnNext(
value);
            }
            
public override void OnCompleted()
            {
                
if (!
_found)
                    
ForwardOnNext(
_defaultValue);
                
ForwardOnCompleted();
            }
        }
        
private readonly IObservable<
TSource> 
_source;
        
private readonly TSource _defaultValue;
        
public DefaultIfEmpty(
IObservable<
TSource> 
source, 
TSource defaultValue)
        {
            
_source = 
source;
            
_defaultValue = 
defaultValue;
        }
        [
return: 
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
            
1,
            
0
        })]
        
protected override _ CreateSink(
IObserver<
TSource> 
observer)
        {
            
return new _(
_defaultValue, 
observer);
        }
        
protected override void Run([
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
            
1,
            
0
        })] 
_ sink)
        {
            
sink.
Run(
_source);
        }
    }
}