• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IObserver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: SuccessTest

 /// <summary>
 /// This will test if the exception has an error code that is not 0 (0 is success), if it does then it sends the observer an OnError.
 /// </summary>
 /// <param name="observer">
 /// The observer.
 /// </param>
 public void SuccessTest(IObserver<IUsbDeviceNotification> observer)
 {
     if (!Win32Error.IsSuccess)
     {
         observer.OnError(Win32Error.Exception);
     }
 }
开发者ID:RichardWilliams,项目名称:WinUsbRx,代码行数:13,代码来源:ProcessHandleResult.cs


示例17: Register

        public void Register(IObserver o)
        {
            _observers.Add(o);

            //When new observers registers, tell the observer what we currently got
            LoadAllWindows();
        }
开发者ID:kim-cv,项目名称:WindowStay,代码行数:7,代码来源:WindowListController.cs


示例18: ReadSegments

        public Task<long> ReadSegments(
            IObserver<RecordSegment> observer,
            Stream stream,
            CancellationToken cancellationToken)
        {
            return Task.Factory.StartNew(() => {
                var scanner = (IScanner) Activator.CreateInstance(this.SegmentsScannerType);
                var initialOffset = stream.Position;
                var lastOffset = initialOffset;

                scanner.OffsetCallback = (offset, length) => {
                    if (length > 0 && offset >= 0) {
                        var segment = new RecordSegment(initialOffset + offset, length);
                        lastOffset = initialOffset + offset + length;
                        observer.OnNext(segment);
                    }
                };

                scanner.Diagnostics = this.Diagnostics ?? TextWriter.Null;

                scanner.SetSourceWithEncoding(
                    new InternalStreamWrapper(stream, stream.Position),
                    Encoding.UTF8.CodePage);

                scanner.Parse(cancellationToken);

                return lastOffset;
            }, cancellationToken,
                TaskCreationOptions.LongRunning,
                this.TaskScheduler);
        }
开发者ID:SmartFire,项目名称:LogWatch,代码行数:31,代码来源:LexLogFormat.cs


示例19: Attach

 public void Attach(IObserver observerMe)
 {
     if (!_observers.Contains(observerMe))
     {
         _observers.Add(observerMe);
     }
 }
开发者ID:entvex,项目名称:GoFSchoolCode,代码行数:7,代码来源:Subject.cs


示例20: RunAsync

        public async Task RunAsync(IObserver<string> observer)
        {
            var urls = new[]
            {
                "http://yahoo.co.jp",
                "http://google.co.jp",
                "http://bing.co.jp",
                "http://awsedrftgyhujikol.jp/",
            };

            foreach (var url in urls)
            {
                await Observable.Timer(TimeSpan.FromSeconds(1));

                try
                {
                    var res = await GetAsStringAsync(url);
                    observer.OnNext(res);
                }
                catch(Exception ex)
                {
                    observer.OnError(ex);
                }
            }
        }
开发者ID:ufcpp,项目名称:AwaitableUniRx,代码行数:25,代码来源:Class1.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IOffsetAttribute类代码示例发布时间:2022-05-24
下一篇:
C# IObservable类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap