<PackageReference Include="System.Reactive" Version="6.1.0-preview.9" />
    
	
	
		
		
		
	 
	
	
        
                
                If<TResult>
                
                
                
                
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 If<[
System.
Runtime.
CompilerServices.
Nullable(
2)] 
TResult> : 
Producer<
TResult, 
If<
TResult>.
_>, 
IEvaluatableObservable<
TResult>
    {
        [
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
            
0,
            
1
        })]
        
internal sealed class _ : 
IdentitySink<
TResult>
        {
            
private readonly If<
TResult> 
_parent;
            
public _(
If<
TResult> 
parent, 
IObserver<
TResult> 
observer)
                : 
base(
observer)
            {
                
_parent = 
parent;
            }
            
public void Run()
            {
                
IObservable<
TResult> 
source;
                
try {
                    
source = 
_parent.
Eval();
                } 
catch (
Exception error) {
                    
ForwardOnError(
error);
                    
return;
                }
                
SetUpstream(
ObservableExtensions.
SubscribeSafe<
TResult>(
source, (
IObserver<
TResult>)
this));
            }
        }
        
private readonly Func<
bool> 
_condition;
        
private readonly IObservable<
TResult> 
_thenSource;
        
private readonly IObservable<
TResult> 
_elseSource;
        
public If(
Func<
bool> 
condition, 
IObservable<
TResult> 
thenSource, 
IObservable<
TResult> 
elseSource)
        {
            
_condition = 
condition;
            
_thenSource = 
thenSource;
            
_elseSource = 
elseSource;
        }
        
public IObservable<
TResult> 
Eval()
        {
            
if (!
_condition())
                
return _elseSource;
            
return _thenSource;
        }
        [
return: 
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
            
1,
            
0
        })]
        
protected override _ CreateSink(
IObserver<
TResult> 
observer)
        {
            
return new _(
this, 
observer);
        }
        
protected override void Run([
System.
Runtime.
CompilerServices.
Nullable(
new byte[] {
            
1,
            
0
        })] 
_ sink)
        {
            
sink.
Run();
        }
    }
}