当前位置: 首页>>代码示例>>C#>>正文


C# IObservable.Select方法代码示例

本文整理汇总了C#中IObservable.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.Select方法的具体用法?C# IObservable.Select怎么用?C# IObservable.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IObservable的用法示例。


在下文中一共展示了IObservable.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MobileApiInfo

        public MobileApiInfo(IObservable<IReadOnlyList<MobileClient>> connectedClients, IObservable<bool> isPortOccupied)
        {
            if (connectedClients == null)
                throw new ArgumentNullException("connectedClients");

            if (isPortOccupied == null)
                throw new ArgumentNullException("isPortOccupied");

            this.IsPortOccupied = isPortOccupied;

            this.VideoPlayerToggleRequest = connectedClients.Select(x => x.Select(y => y.VideoPlayerToggleRequest).Merge()).Switch();
            this.ConnectedClientCount = connectedClients.Select(x => x.Count);
        }
开发者ID:reactiveui-forks,项目名称:Espera,代码行数:13,代码来源:MobileApiInfo.cs

示例2: JoinRoom

        public IObservable<ChatEvent> JoinRoom(string room, string user, IObservable<string> messages)
        {
            // Get or create the room being requested.
            var roomStream = this.GetOrAddRoom(room);

            // Send a happy little join message.
            roomStream.OnNext(new ChatEvent
                              {
                                  User = user,
                                  Message = "Joined!",
                                  Time = DateTime.UtcNow,
                                  Type = "presence"
                              });

            // Turn incoming messages into chat events and pipe them into the room.
            messages.Select(message => new ChatEvent
                                       {
                                           User = user,
                                           Message = message,
                                           Time = DateTime.UtcNow
                                       })
                .Subscribe(
                    roomStream.OnNext,
                    () => roomStream.OnNext(new ChatEvent
                                            {
                                                User = user,
                                                Message = "Left.",
                                                Time = DateTime.UtcNow,
                                                Type = "presence"
                                            }));

            return roomStream;
        }
开发者ID:WebStreams,项目名称:WebStreams.Samples,代码行数:33,代码来源:ChatRoomController.cs

示例3: RiakStreamedMapReduceResult

 internal RiakStreamedMapReduceResult(IObservable<RpbMapRedResp> responseReader)
 {
     _responseReader = responseReader
         .Select(item => new RiakMapReduceResultPhase(item.phase, new List<RpbMapRedResp> { item }))
         .ToEnumerable()
         .ToList();
 }
开发者ID:taliesins,项目名称:CorrugatedIron,代码行数:7,代码来源:RiakStreamedMapReduceResult.cs

示例4: Calculate

        public virtual IObservable<double> Calculate(IObservable<double> samples)
        {
            var q = new Queue<double>();
            var sma = double.NaN;

            return samples.Select(x =>
            {
                q.Enqueue(x);

                if (double.IsNaN(sma))
                {
                    sma = x;
                    return x;
                }

                if (q.Count <= N)
                {
                    sma = q.Sum() / q.Count;
                }
                else
                {
                    sma = sma + (x / N) - (q.Dequeue() / N);
                }

                return sma;
            });
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:27,代码来源:SimpleMovingAverage.cs

示例5: Threshold

        public Threshold(IObservable<int> thresholdState)
        {
            //this.WhenAny(vm => vm.Good, vm => vm.Bad, vm => vm.OK, (g, b, o) =>
            //{

            //});

            this.Good = new Range();
            this.Bad = new Range();
            this.OK = new Range();

            var obs = thresholdState.Select(value =>
               {
                   if (value.Between(this.Good.Min, this.Good.Max))
                       return "Good";

                   if (value.Between(this.OK.Min, this.ok.Max))
                       return "OK";

                   if (value.Between(this.Bad.Min, this.bad.Max))
                       return "Bad";

                   return "";
               });

            this.state = obs.ToProperty(this, vm => vm.State);
            obs.Subscribe(_ =>
            {
                Trace.WriteLine(_);
            });
        }
开发者ID:abbottdev,项目名称:gitreminder,代码行数:31,代码来源:Threshold.cs

示例6: MainWindowViewModel

        public MainWindowViewModel()
        {
            _iTunes = new iTunes().AddTo(CompositeDisposable);

            var currentTrack = Observable.Interval(TimeSpan.FromSeconds(0.5))
                                         .Select(_ => _iTunes.GetCurrentTrack())
                                         .Where(track => track != null)
                                         .DistinctUntilChanged()
                                         .Publish();

            Title = currentTrack.Select(x => x.Name).ToReactiveProperty();
            Album = currentTrack.Select(x => x.Album).ToReactiveProperty();
            Artist = currentTrack.Select(x => x.Artist).ToReactiveProperty();

            var artwork = currentTrack.Select(x => x.Artwork.FirstOrDefault())
                                      .Where(x => x != null)
                                      .DistinctUntilChanged();

            _colors = artwork.SelectMany(x => x.GetStreamAsync())
                             .Select(x => new Bitmap(x))
                             .Select(Analyzer.GetColors);

            MainColor = _colors.Select(x => x.Item1.ToMediaColor()).ToReactiveProperty();
            AccentColor = _colors.Select(x => x.Item2.ToMediaColor()).ToReactiveProperty();
            SubColor = _colors.Select(x => x.Item3.ToMediaColor()).ToReactiveProperty();

            Artwork = artwork.SelectMany(x => x.GetStreamAsync())
                             .Select(x =>
                             {
                                 var image = x.ToBitmapImage();
                                 image.Freeze();
                                 return image;
                             })
                             .ToReactiveProperty();

            InvertedMainColor = MainColor.CombineLatest(AccentColor, (main, accent) =>
            {
                var mainLuminance = Hsb.GetLuminance(main.ToDrawingColor());
                var accentHsb = Hsb.FromColor(accent.ToDrawingColor());
                var b = mainLuminance > 50 ? 0.1f : 0.9f;
                return accentHsb.SetBrightness(b).ToColor().ToMediaColor();

            }).ToReactiveProperty();

            currentTrack.Connect().AddTo(CompositeDisposable);
        }
开发者ID:chocolamint,项目名称:iTunesHue,代码行数:46,代码来源:MainWindowViewModel.cs

示例7: ValidateFullName

		private static IObservable<string> ValidateFullName(IObservable<string> fullNames)
		{
			return fullNames.Select(
				fullName =>
					{
						if (string.IsNullOrWhiteSpace(fullName)) return "Must specify a full name";
						return null;
					});
		}
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:9,代码来源:HumanViewModel.cs

示例8: SkeletonDispatcher

        public SkeletonDispatcher(IObservable<IEnumerable<SkeletonData>> skeletons)
        {
            Contract.Requires(skeletons != null);

            mySkeletonSubscription =
                skeletons
                .Select(sds => sds.Where(sd => sd.TrackingState != SkeletonTrackingState.NotTracked))
                .Subscribe(OnSkeletonsProduced);
        }
开发者ID:Aesir,项目名称:ObservableKinect,代码行数:9,代码来源:SkeletonDispatcher.cs

示例9: PegCompiler

        public PegCompiler(IObservable<Grammar> grammars)
        {
            var compileResults = grammars
                .Select(r => r == null ? new Compiler.CompileResult(r) : Compiler.PegCompiler.Compile(r))
                .Publish();

            this.Codes = compileResults.Select(r => r.Code);
            this.Errors = compileResults.Select(r => r.Errors.ToList().AsReadOnly());

            this.disposable = compileResults.Connect();
        }
开发者ID:KevinKelley,项目名称:Pegasus,代码行数:11,代码来源:PegCompiler.cs

示例10: Calculate

        /// <summary>
        /// Calculates the Count of given samples.
        /// </summary>
        /// <param name="samples"></param>
        public static IObservable<Decimal> Calculate(IObservable<double> samples)
        {
            var result = (Decimal)0;

            return samples.Select(x =>
            {
                result += Convert.ToDecimal(x);

                return result;
            });
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:15,代码来源:Total.cs

示例11: Calculate

        /// <summary>
        /// Calculates the Count of given samples.
        /// </summary>
        /// <param name="samples"></param>
        public static IObservable<UInt64> Calculate(IObservable<double> samples)
        {
            var result = (UInt64)0;

            return samples.Select(x =>
            {
                result++;

                return result;
            });
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:15,代码来源:Count.cs

示例12: HandleExceptionOccurredMessages

 public HandleExceptionOccurredMessages(
     IPublisher publisher,
     IDispatchServices dispatch,
     IObservable<ExceptionOccurred> exceptionStream1,
     IObservable<ExceptionMsg> exceptionStream2)
 {
     _publisher = publisher;
     exceptionStream1.Select(ex => ex.Exception)
     .Merge(exceptionStream2.Select(ex => ex.Exception))
     .ObserveOn(dispatch)
     .Subscribe(HandleNextException);
 }
开发者ID:flq,项目名称:Thawmadoce,代码行数:12,代码来源:HandleExceptionOccurredMessages.cs

示例13: Filter

        public static IObservable<List<float>> Filter(IObservable<List<float>> src, Func<IObservable<float>, IObservable<float>> filter)
        {
            var channels = new List<IObservable<float>>(8);
            for (var index = 0; index < 8; index++)
            {
                var chIndex = index;
                var channel = filter(src.Select(values => values[chIndex]));
                channels.Add(channel);
            }

            return channels.Zip(ilist => ilist.ToList());
        }
开发者ID:Shinbuev,项目名称:Orthopedy,代码行数:12,代码来源:UnwildZipFilter.cs

示例14: Center

        public IObservable<PointF> Center(IObservable<List<float>> channelsObservable)
        {
            return channelsObservable.Select(channels =>
            {
                if (channels != null && channels.Count == 4)
                {
                    return CalculateCenterOf(channels);
                }

                return GeometricalCenter;
            });
        }
开发者ID:Shinbuev,项目名称:Orthopedy,代码行数:12,代码来源:PlatformDiagnostic.cs

示例15: ToIterate_Complete

        IEnumerable<IObservable<Object>> ToIterate_Complete(IObservable<int> xs, IObservable<int> ys, IObservable<int> zs, IObserver<int> observer)
        {
            observer.OnNext(1);
            yield return xs.Select(x => new Object());

            observer.OnNext(2);
            yield return ys.Select(x => new Object());

            observer.OnNext(3);
            observer.OnCompleted();
            yield return zs.Select(x => new Object());

            observer.OnNext(4);
        }
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:14,代码来源:ObservableExTest.cs


注:本文中的IObservable.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。