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


C# IObserver类代码示例

本文整理汇总了C#中IObserver的典型用法代码示例。如果您正苦于以下问题:C# IObserver类的具体用法?C# IObserver怎么用?C# IObserver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: AppendEntryBaseTest

        protected AppendEntryBaseTest()
        {
            // Arrange  
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();

            mocker.Use(ServerIdentifier);

            mocker.Setup<ISubject<AppendEntryMessage>>(p => p.Subscribe(It.IsAny<IObserver<AppendEntryMessage>>()))
                .Callback<IObserver<AppendEntryMessage>>((o) =>
                {
                    AppendEntryCallback = o;
                });
            AppendEntryCallback = mocker.Get<ISubject<AppendEntryMessage>>();

            AppendEntryResult = new Subject<AppendEntryResultMessage>();
            Election = new Election();
            LogReplication = new LogReplication();
            
            AppendEntry = new Rafting.AppendEntry(AppendEntryResult,
                mocker.Get<ISubject<AppendEntryMessage>>(),
                mocker.Get<IHartbeatTimer>(),
                LogReplication,
                Election,
                mocker.Get<ILoggerFactory>(),
                new RaftOptions(),
                mocker.Get<ServerIdentifier>(),
                null);
        }
开发者ID:RossMerr,项目名称:Caudex.Rafting,代码行数:30,代码来源:AppendEntryBaseTest.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: AddObserver

 public void AddObserver(IObserver observer)
 {
     if (observer != null && !m_ObserverList.Contains(observer))
     {
         m_ObserverList.Add(observer);
     }
 }
开发者ID:Collegiennes,项目名称:Malisse,代码行数:7,代码来源:Subject.cs

示例4: RegisterObserver

        public void RegisterObserver(IObserver observer)

        {

            observable.RegisterObserver(observer);

        }
开发者ID:Gittre,项目名称:HeadFirstDesignPatterns,代码行数:7,代码来源:DuckCall.cs

示例5: UnRegister

 public void UnRegister(IObserver anObserver)
 {
     try {
     this.observerContainer.Remove(anObserver);
       } catch {
       }
 }
开发者ID:AdamCarrick,项目名称:inbefore404,代码行数:7,代码来源:windowPreferences.xaml.cs

示例6: RxTimerStage

 /// <summary>Constructs a Rx timer stage</summary>
 /// <param name="observer">the observer</param>
 /// <param name="initialDelay">the initial delay in milli-seconds</param>
 /// <param name="period">the period in milli-seconds</param>
 public RxTimerStage(IObserver<PeriodicEvent> observer, long initialDelay, long period)
 {
     _observer = observer;
     _timer = new Timer(period);
     _timer.Elapsed += (sender, e) => OnTimedEvent(sender, e, _observer, _value);
     _timer.Enabled = true;
 }
开发者ID:beomyeol,项目名称:reef,代码行数:11,代码来源:RxTimerStage.cs

示例7: RegisterObserver

        public void RegisterObserver(IObserver o)

        {

            observers.Add(o);

        }
开发者ID:Gittre,项目名称:HeadFirstDesignPatterns,代码行数:7,代码来源:WeatherData.cs

示例8: Detach

 public void Detach(IObserver observer)
 {
     if (_people.Contains(observer))
        {
             _people.Add(observer);
        }
 }
开发者ID:JohnyLica,项目名称:ProjectComp,代码行数:7,代码来源:MagLocation.cs

示例9: SinkSettings

        /// <summary>
        /// Initializes a new instance of the <see cref="SinkSettings" /> class.
        /// </summary>
        /// <param name="name">The event listener name.</param>
        /// <param name="sink">The sink instance.</param>
        /// <param name="eventSources">The event sources.</param>
        /// <exception cref="ConfigurationException">Validation exceptions.</exception>
        public SinkSettings(string name, IObserver<EventEntry> sink, IEnumerable<EventSourceSettings> eventSources)
            : this(name, eventSources)
        {
            Guard.ArgumentNotNull(sink, "sink");

            this.Sink = sink;
        }
开发者ID:EdHastings,项目名称:semantic-logging,代码行数:14,代码来源:SinkSettings.cs

示例10: Add

 /// <summary>
 /// ��ӹ۲���
 /// </summary>
 /// <param name="observer"></param>
 public void Add(IObserver observer)
 {
     lock (this)
     {
         root.Add(observer);
     }
 }
开发者ID:dalinhuang,项目名称:videospstandalonenew,代码行数:11,代码来源:CommDataMgr.cs

示例11: Unsubscribe

 public void Unsubscribe(IObserver observer)
 {
     if (_observers.Contains(observer))
     {
         _observers.Remove(observer);
     }
 }
开发者ID:celadin,项目名称:DesignPatternsExamples,代码行数:7,代码来源:StockTicker.cs

示例12: AddObserver

 public virtual void AddObserver( IObserver newObserver )
 {
     if ( listOfObservers.Contains( newObserver ) ) {
         return;
     }
     listOfObservers.Add( newObserver );
 }
开发者ID:dirty-casuals,项目名称:Calamity,代码行数:7,代码来源:SubjectObject.cs

示例13: RunAsync

 public static DataReaderObservableRunner RunAsync(IDbCommand command, IObserver<IDictionary<string, object>> observer)
 {
     var instance = new DataReaderObservableRunner(command, observer);
     var asyncAction = new Action(instance.Run);
     asyncAction.BeginInvoke(asyncAction.EndInvoke, null);
     return instance;
 }
开发者ID:robashton,项目名称:Simple.Data,代码行数:7,代码来源:DataReaderObservableRunner.cs

示例14: ExecuteInstall

        public IObservable<List<string>> ExecuteInstall(string currentAssemblyDir, IPackage bundledPackageMetadata, IObserver<int> progress = null)
        {
            progress = progress ?? new Subject<int>();

            // NB: This bit of code is a bit clever. The binaries that WiX 
            // has installed *itself* meets the qualifications for being a
            // Squirrel update directory (a RELEASES file and the corresponding 
            // NuGet packages). 
            //
            // So, in order to reuse some code and not write the same things 
            // twice we're going to "Eigenupdate" from our own directory; 
            // UpdateManager will operate in bootstrap mode and create a 
            // local directory for us. 
            //
            // Then, we create a *new* UpdateManager whose target is the normal 
            // update URL - we can then apply delta updates against the bundled 
            // NuGet package to get up to vCurrent. The reason we go through
            // this rigamarole is so that developers don't have to rebuild the 
            // installer as often (never, technically).

            var updateUsingDeltas =
                executeInstall(currentAssemblyDir, bundledPackageMetadata, progress: progress)
                        .ToObservable()
                        .ObserveOn(RxApp.DeferredScheduler)
                        .Catch<List<string>, Exception>(ex => {
                    log.WarnException("Updating using deltas has failed", ex);
                    return executeInstall(currentAssemblyDir, bundledPackageMetadata, true, progress)
                                 .ToObservable();
            });

            return updateUsingDeltas;
        }
开发者ID:rzhw,项目名称:Squirrel.Windows,代码行数:32,代码来源:InstallManager.cs

示例15: ScheduledMethod

        private static IDisposable ScheduledMethod(IObserver<int> o)
        {
            var cancel = new CancellationDisposable();
            // internally creates a new CancellationTokenSource
            NewThreadScheduler.Default.Schedule(() =>
                                                    {
                                                        int i = 0;
                                                        for (;;)
                                                        {
                                                            Thread.Sleep(200);
                                                            // here we do the long lasting background operation
                                                            if (!cancel.Token.IsCancellationRequested)
                                                                // check cancel token periodically
                                                                o.OnNext(i++);
                                                            else
                                                            {
                                                                Console.WriteLine(
                                                                    "Aborting because cancel event was signaled!");
                                                                o.OnCompleted();
                                                                return;
                                                            }
                                                        }
                                                    }
                );

            return cancel;
        }
开发者ID:bFanatic,项目名称:RX-StateMachine,代码行数:27,代码来源:RxWithCancelation.cs


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