| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 | <#@ template debug="false" hostspecific="false" language="C#" #><#@ assembly name="System.Core" #><#@ import namespace="System.Linq" #><#@ import namespace="System.Text" #><#@ import namespace="System.Collections.Generic" #><#@ output extension=".cs" #>// Licensed to the .NET Foundation under one or more agreements.// The .NET Foundation licenses this file to you under the Apache 2.0 License.// See the LICENSE file in the project root for more information. #if !NO_PERFusing System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Reactive.Disposables;namespace System.Reactive.Linq.ObservableImpl{	#region [3,16]-ary    /* The following code is generated by a T4 template. */    #region CombineLatest auto-generated code (<#=DateTime.Now.ToString()#>)<#for (var i = 3; i <= 16; i++){	var ts = string.Join(", ", Enumerable.Range(1, i).Select(j => "T" + j));	var os = string.Join(", ", Enumerable.Range(1, i).Select(j => "IObservable<T" + j + "> source" + j));	var vs = string.Join(", ", Enumerable.Range(1, i).Select(j => "_observer" + j + ".Value"));	if (i == 5)	{#>#if !NO_LARGEARITY<#	}#>	class CombineLatest<<#=ts#>, TResult> : Producer<TResult>    {<#for (var j = 1; j <= i; j++){#>        private readonly IObservable<T<#=j#>> _source<#=j#>;<#}#>        private readonly Func<<#=ts#>, TResult> _resultSelector;        public CombineLatest(<#=os#>, Func<<#=ts#>, TResult> resultSelector)        {<#for (var j = 1; j <= i; j++){#>            _source<#=j#> = source<#=j#>;<#}#>            _resultSelector = resultSelector;        }        protected override IDisposable Run(IObserver<TResult> observer, IDisposable cancel, Action<IDisposable> setSink)        {            var sink = new _(this, observer, cancel);            setSink(sink);            return sink.Run();        }        class _ : CombineLatestSink<TResult>        {            private readonly CombineLatest<<#=ts#>, TResult> _parent;            public _(CombineLatest<<#=ts#>, TResult> parent, IObserver<TResult> observer, IDisposable cancel)                : base(<#=i#>, observer, cancel)            {                _parent = parent;            }<#for (var j = 1; j <= i; j++){#>            private CombineLatestObserver<T<#=j#>> _observer<#=j#>;<#}#>            public IDisposable Run()            {                var subscriptions = new SingleAssignmentDisposable[<#=i#>];                for (int i = 0; i < <#=i#>; i++)                    subscriptions[i] = new SingleAssignmentDisposable();<#for (var j = 1; j <= i; j++){#>				_observer<#=j#> = new CombineLatestObserver<T<#=j#>>(_gate, this, <#=j - 1#>, subscriptions[<#=j - 1#>]);<#}#>                <#for (var j = 1; j <= i; j++){#>                subscriptions[<#=j - 1#>].Disposable = _parent._source<#=j#>.SubscribeSafe(_observer<#=j#>);<#}#>                return StableCompositeDisposable.Create(subscriptions);            }            protected override TResult GetResult()            {                return _parent._resultSelector(<#=vs#>);            }        }    }<#}#>#endif	#endregion	#endregion}#endif
 |