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


C# IObservable.Subscribe方法代码示例

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


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

示例1: CMTPoint

 public CMTPoint(double ttm_, CMT cmt_, /*int series_,*/ IObservable<alglib.spline1dinterpolant> fitProvider_)
 {
   TimeToMaturity = ttm_;
   //Series = series_;
   m_parent = cmt_;
   m_disp = fitProvider_.Subscribe(OnNext);
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:7,代码来源:CMTPoint.cs

示例2: Leader

        public Leader(IElection election, 
            IHartbeatTimer hartbeat,
            IObservable<AppendEntryResultMessage> reply,
            IObserver<AppendEntryMessage> append,
            IObserver<ClientResultMessage> clientReply,
            IObservable<ClientMessage> client,
            ILogReplication logReplication, 
            Nodes nodes,
            ILoggerFactory loggerFactory,
            RaftOptions options, 
            ServerIdentifier serverIdentifier)
        {
            _isDispose = false;
            _hartbeat = hartbeat;
            _append = append;
            _clientReply = clientReply;
            _client = client;
            _logReplication = logReplication;
            _nodes = nodes;
            _options = options;
            _serverIdentifier = serverIdentifier;
            _election = election;
            _logger = loggerFactory.CreateLogger(nameof(Leader) + " " + serverIdentifier);

            if (_options.UseLogging)
                _logger.LogInformation($"{nameof(ServerStateType.Leader)}");

            // Reinitialized after election
            NextIndex = new ConcurrentDictionary<ServerIdentifier, int>();
            MatchIndex = new ConcurrentDictionary<ServerIdentifier, int>();
            _hartbeat.Leader(SendHartbeat);
            _replyDispose = reply.Subscribe(EntryReplyMessageRecived);
            _clientReplyDispose = client.Subscribe(ClientMessageRecived);
        }
开发者ID:RossMerr,项目名称:Caudex.Rafting,代码行数:34,代码来源:Leader.cs

示例3: Execute

        public IObservable<TestResult> Execute(IObservable<TestMethod> tests)
        {
            return Observable.Create(
                (IObserver<TestResult> observer) =>
                    {
                        tests.Subscribe(
                            onNext: test =>
                            {
                                try
                                {
                                    var declaringType = test.Method.DeclaringType;
                                    var instance = Activator.CreateInstance(declaringType);
                                    test.Method.Invoke(instance, test.Parameters);
                                    observer.OnNext(new TestResult(test.Uri, test.Method));
                                }
                                catch (Exception ex)
                                {
                                    observer.OnNext(new TestResult(test.Uri, test.Method, ex));
                                }
                            },
                            onError:observer.OnError,
                            onCompleted:observer.OnCompleted);

                        return Disposable.Empty;
                    });
        }
开发者ID:nikmd23,项目名称:CrawlRunner,代码行数:26,代码来源:TestExecutor.cs

示例4: Display

        public void Display(IObservable<TestResult> results)
        {
            results.Subscribe(
                onNext: result =>
                    {
                        Console.WriteLine("\n{0}.{1} for {2} : {3}",
                                          result.Test.DeclaringType.FullName,
                                          result.Test.Name,
                                          result.Uri,
                                          result.Success ? "Success" : "Failed");

                        if (!result.Success)
                        {
                            Console.Error.WriteLine(result.Exception);
                            Failures.Add(string.Format("\n{0}.{1} for {2}\n{3}",
                                                       result.Test.DeclaringType.FullName,
                                                       result.Test.Name,
                                                       result.Uri.AbsoluteUri,
                                                       result.Exception.Message));
                        }

                        Count++;
                    },
                onError: WriteMessage,
                onCompleted: WriteMessage);
        }
开发者ID:nikmd23,项目名称:CrawlRunner,代码行数:26,代码来源:ConsoleOutput.cs

示例5: DeadCountersDetector

        public DeadCountersDetector(IObservable<LogEventArgs> observableEvents, Settings settings)
        {
            _observableEvents = observableEvents;
            _settings = settings;
            _observableEvents.Subscribe(UpdateCounterFreshnessTime);

        }
开发者ID:demonix,项目名称:iPoint.ServiceStatistics,代码行数:7,代码来源:DeadCountersDetector.cs

示例6: WindowController

        public WindowController(IObservable<LoadData> controls)
        {
            InitializeComponent();

            disposable = controls.Subscribe(c => Load(c.View),
            Close
            );
        }
开发者ID:github,项目名称:VisualStudio,代码行数:8,代码来源:WindowController.xaml.cs

示例7: Subscribe

        public IDisposable Subscribe(IObservable<string> observable)
        {
            return observable.Subscribe(d =>
            {
                var bytes = Encoding.ASCII.GetBytes(d);

                _client.Send(bytes, bytes.Length);
            });
        }
开发者ID:WillemRB,项目名称:DataGenerator,代码行数:9,代码来源:UdpSink.cs

示例8: Activate

 public static IDisposable Activate(this IAlertDialogFactory @this, IObservable<bool> observable, string text)
 {
     return observable.Subscribe(x => {
         if (x)
             @this.Show(text);
         else
             @this.Hide();
     });
 }
开发者ID:runt18,项目名称:CodeHub,代码行数:9,代码来源:AlertDialogExtensions.cs

示例9: TrayIcon

 public TrayIcon(IObservable<ITrayNotification> notifications) {
     InitializeComponent();
     Application.Current.Exit += (sender, args) => TaskbarIcon.Dispose();
     _notificationQueue = new ConcurrentQueue<ITrayNotification>();
     // TODO: Just attach through ViewModel instead...
     notifications.Subscribe(x => {
         _notificationQueue.Enqueue(x);
         ProcessNotificationQueue();
     });
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:10,代码来源:TrayIcon.xaml.cs

示例10: BurnScrap

 public void BurnScrap(IObservable<FileSystemEntity> source)
 {
     _subscription = source.Subscribe(entity =>
     {
         if (entity.File != null)
             entity.File.Delete();
         else
             entity.Directory.Delete(true);
     });
 }
开发者ID:cburgdorf,项目名称:Blockbuster,代码行数:10,代码来源:ScrapHeap.cs

示例11: GameStateService

		public GameStateService(ObservableTimerService timerService)
		{
			if (timerService == null) throw new ArgumentNullException();
			
			_timerService = timerService;
			_timeSequence = _timerService.GetTimerSequence(100*1000, 1000);
			_timeSubscription = _timeSequence.Subscribe(newTime => ClockTime = newTime / 1000);

			Direction = true;
		}
开发者ID:bpe78,项目名称:WpfExamples,代码行数:10,代码来源:GameStateService.cs

示例12: ObservableCommand

        public ObservableCommand(IObservable<bool> canExecuteObservable, Func<object, Task> action)
        {
            this.action = action;

            canExecuteSubscription = canExecuteObservable.Subscribe(b =>
            {
                latest = b;
                RaiseCanExecuteChanged();
            });
        }
开发者ID:distantcam,项目名称:ServiceInsight2,代码行数:10,代码来源:ObservableCommand.cs

示例13: RepositoryPrincipalFactory

		public RepositoryPrincipalFactory(
			IQueryable<IUserRoles> loadRoles,
			IObservable<Lazy<IUserRoles>> roleChanges)
		{
			Contract.Requires(loadRoles != null);
			Contract.Requires(roleChanges != null);

			this.LoadRoles = loadRoles;
			Subscription = roleChanges.Subscribe(_ => RefreshCache());
			RefreshCache();
		}
开发者ID:dstimac,项目名称:revenj,代码行数:11,代码来源:RepositoryPrincipalFactory.cs

示例14: immediately_completes_when_subscribed_to_with_no_scheduler

        public void immediately_completes_when_subscribed_to_with_no_scheduler()
        {
            obs = Observable.Empty<int>();

            bool completed = false;

            using (obs.Subscribe(x => { }, () => completed = true))
            {
                Assert.IsTrue(completed);
            }
        }
开发者ID:richardszalay,项目名称:raix,代码行数:11,代码来源:EmptyEventFixture.cs

示例15: Trigger

        public Trigger(Func<Task> action, IObservable<Input> trigger)
        {
            Disposable = trigger.Subscribe(async input =>
                {
                    var prev = Interlocked.CompareExchange(ref Latch, 1, 0);
                    if (0 != prev)
                        return;

                    await action();
                    Latch = 0;
                });
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:12,代码来源:Trigger.cs


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