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


C# IObservable.CombineLatest方法代码示例

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


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

示例1: LineScroller

        public LineScroller(FileInfo file,
                IObservable<ILineProvider> latest,
                IObservable<ScrollRequest> scrollRequest,
                ILogger logger,
                IScheduler scheduler = null)
        {
            if (file == null) throw new ArgumentNullException(nameof(file));
            if (latest == null) throw new ArgumentNullException(nameof(latest));
            if (logger == null) throw new ArgumentNullException(nameof(logger));

            logger.Info($"Constructing file tailer for {file.FullName}");

            var lines = new SourceCache<Line, LineKey>(l=>l.Key);
            Lines = lines.AsObservableCache();

            var locker = new object();
            scrollRequest = scrollRequest.Synchronize(locker);


            var aggregator = latest.CombineLatest(scrollRequest, (currentLines, scroll) => currentLines.ReadLines(scroll).ToArray())
                .Subscribe(currentPage =>
                {
                    var previous = lines.Items.ToArray();
                    var added = currentPage.Except(previous,Line.TextStartComparer).ToArray();
                    var removed = previous.Except(currentPage, Line.TextStartComparer).ToArray();

                    lines.Edit(innerCache =>
                    {
                        if (removed.Any()) innerCache.Remove(removed);
                        if (added.Any()) innerCache.AddOrUpdate(added);
                    });
                });

            _cleanUp = new CompositeDisposable(Lines, lines, aggregator);
        }
开发者ID:abuzhynsky,项目名称:TailBlazer,代码行数:35,代码来源:LineScroller.cs

示例2: Emit

        public IObservable<NavigationInformation> Emit(IObservable<NavigationInformation> Navigation)
        {
            ICanPortHandler canPortHandler = _canPortHandlerProvider.OpenPort();

            IObservable<long> speedSampler = Observable.Interval(TimeSpan.FromMilliseconds(200));
            IObservable<long> gpsSampler = Observable.Interval(TimeSpan.FromMilliseconds(1000));

            var sub = new CompositeDisposable(
                canPortHandler,
                Navigation.CombineLatest(speedSampler, (n, i) => n)
                          .Sample(speedSampler)
                          .Subscribe(n => EmitSpeed(canPortHandler.Port, n.Speed)),
                Navigation.CombineLatest(gpsSampler, (n, i) => n)
                          .Sample(gpsSampler)
                          .Subscribe(n => EmitPosition(canPortHandler.Port, n.Position, n.Reliability)));

            Navigation.Subscribe(_ => { }, sub.Dispose);
            return Navigation;
        }
开发者ID:NpoSaut,项目名称:netEMapTools,代码行数:19,代码来源:CanBlokEmitter.cs

示例3: TestParser

        public TestParser(IObservable<dynamic> parsers, IObservable<string> subjects)
        {
            var testParserResults = subjects
                .CombineLatest(parsers, (subject, parser) => new { subject, parser = (object)parser })
                .ObserveOn(Scheduler.Default)
                .Select(p => ParseTest(p.parser, p.subject))
                .Publish()
                .RefCount();

            this.Results = testParserResults.Select(r => r.Result);
            this.Errors = testParserResults.Select(r => r.Errors);
        }
开发者ID:otac0n,项目名称:Pegasus,代码行数:12,代码来源:TestParser.cs

示例4: PegParser

        public PegParser(IObservable<string> subjects, IObservable<string> fileNames)
        {
            var internalParseResults = subjects.CombineLatest(fileNames, (subject, filename) => new { subject, filename })
                .Throttle(TimeSpan.FromMilliseconds(10), Scheduler.Default)
                .Select(p => Parse(p.subject, p.filename))
                .Publish();

            this.Grammars = internalParseResults.Select(g => g.Grammar);
            this.Errors = internalParseResults.Select(g => g.Errors.AsReadOnly());
            this.LexicalElements = internalParseResults.Select(g => g.LexicalElements);

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

示例5: CsCompiler

        public CsCompiler(IObservable<Tuple<string, Grammar>> codeAndGrammar, IObservable<string> fileNames)
        {
            var csCompilerResults = codeAndGrammar
                .CombineLatest(fileNames, (cg, fileName) => new { code = cg.Item1, grammar = cg.Item2, fileName })
                .Throttle(TimeSpan.FromMilliseconds(10), Scheduler.Default)
                .Select(p => Compile(p.code, p.grammar, p.fileName))
                .Publish();

            this.Parsers = csCompilerResults.Select(r => r.Parser);
            this.Errors = csCompilerResults.Select(r => r.Errors.AsReadOnly());

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

示例6: Emit

        public IObservable<NavigationInformation> Emit(IObservable<NavigationInformation> Navigation)
        {
            var udpClient = new UdpClient();
            udpClient.Connect(RemoteAddress, Port);

            IObservable<long> speedSampler = Observable.Interval(TimeSpan.FromMilliseconds(500));
            IObservable<long> gpsSampler = Observable.Interval(TimeSpan.FromMilliseconds(1000));

            var sub = new CompositeDisposable(
                udpClient,
                Navigation.CombineLatest(speedSampler, (n, i) => n)
                          .Sample(speedSampler)
                          .TimeInterval()
                          .Scan(0.0, (dst, tn) => dst + (tn.Interval.TotalHours * tn.Value.Speed * 1000))
                          .Subscribe(disstance => EmitSpeed(udpClient, disstance)),
                Navigation.CombineLatest(gpsSampler, (n, i) => n)
                          .Sample(gpsSampler)
                          .Subscribe(n => EmitPosition(udpClient, n.Position, n.Reliability)));

            Navigation.Subscribe(_ => { }, sub.Dispose);
            return Navigation;
        }
开发者ID:NpoSaut,项目名称:netEMapTools,代码行数:22,代码来源:UdpBlokEmitter.cs

示例7: TestParser

        public TestParser(IObservable<dynamic> parsers, IObservable<string> subjects, IObservable<string> fileNames)
        {
            var testParserResults = subjects
                .CombineLatest(fileNames, (subject, fileName) => new { subject, fileName })
                .CombineLatest(parsers, (p, parser) => new { p.subject, p.fileName, parser = (object)parser })
                .Throttle(TimeSpan.FromMilliseconds(10), Scheduler.Default)
                .Select(p => ParseTest(p.parser, p.subject, p.fileName))
                .Publish();

            this.Results = testParserResults.Select(r => r.Result);
            this.Errors = testParserResults.Select(r => r.Errors.AsReadOnly());

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

示例8: Start

	void Start () {
		//Time
		rx_player_time = source.rx_score.Select(score=>{
			return score.time.played_for;
		});
		rx_goal_time = source.rx_score.SelectMany(score=>{
			return score.settings.time.rx_game_length;
		});
		
		//Distance
		rx_player_distance = source.rx_score.Select(score=>{
			return score.time.distance_covered;
		});
		rx_distance_target = source.rx_score.Select(score=>{
			return score.settings.win_condition.distance_covered;
		});
		
		//Icons
		rx_player_time.CombineLatest(rx_goal_time, (player, goal)=>{
			return new {player = player, goal = goal};
		}).Subscribe(data => {
			update_section(data.player, data.goal, time_icon, GameTimer.to_stopwatch, time_recorded_text, time_goal_text);
		});

		rx_player_distance.CombineLatest(rx_distance_target, (player, goal)=>{
			return new {player = player, goal = goal};
		}).Subscribe(data => {
			update_section(data.player, data.goal.target, distance_icon, (distance)=>{
				return distance.ToString("0.00")+" m";
			}, distance_recorded_text, distance_goal_text);

			//Handle the score totals since we have the needed data.
			float flat_score = data.goal.flat_value(data.player);
			float range_score = data.goal.range_value(data.player);
			float total_score = flat_score + range_score;
			ScoreDetailedForm.format_score_text(flat_score_text, flat_score);
			ScoreDetailedForm.format_score_text(range_score_text, range_score);
			ScoreDetailedForm.format_score_text(total_score_text, total_score);
		});
		
		//Average Speed
		rx_player_time.CombineLatest(rx_player_distance, (time, distance)=>{
			return distance/time;
		}).Subscribe(speed=>{
			average_speed_text.text = speed.ToString("0.00")+" m/s";
		});
		
		//Flat Score
	}
开发者ID:mrunderhill89,项目名称:guardian_of_the_fields_the_strawberry_jam,代码行数:49,代码来源:ScoreTimelineView.cs

示例9: Add

 private static IObservable<Vector3<int>> Add(IObservable<Vector3<int>> arg1, IObservable<Vector3<int>> arg2)
 {
     return arg1.CombineLatest(arg2, (a, b) => a + b);
 }
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:4,代码来源:Program.cs


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