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


C# Subject.Merge方法代码示例

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


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

示例1: MergingEvents

        public void MergingEvents()
        {
            var first = new List<String>();
            var both = new List<String>();
            var s1 = new Subject<String>();
            var s2 = new Subject<String>();
            s1.Subscribe(s => first.Add(s));
            s1.Merge(s2).Subscribe(s => both.Add(s));

            s1.OnNext("I");
            s1.OnNext("am");
            s2.OnNext("nobody.");
            s2.OnNext("Nobody");
            s2.OnNext("is");
            s1.OnNext("perfect.");

            Assert.AreEqual("I am nobody. Nobody is perfect.", String.Join(" ",both));
            Assert.AreEqual("I am perfect.", String.Join(" ",first));
        }
开发者ID:alwalker,项目名称:rx_koans,代码行数:19,代码来源:Lesson6AdvancedStreams.cs

示例2: Main_Loaded

        void Main_Loaded(object sender, RoutedEventArgs e)
        {
            var traceListener = new TextTraceListener();
            System.Diagnostics.Trace.Listeners.Add(traceListener);

            traceListener.TextOut.Subscribe(s => Dispatcher.Invoke(() =>
                {
                    UiTraceOut.Text += s;
                    ScrollParent(UiTraceOut);
                }));

            Browser.PropertyChanged += (o, args) =>
                {
                    if (args.PropertyName == "SelectedScriptPath")
                    {
                        Dispatcher.Invoke(() =>
                        {
                            var path = Browser.SelectedScriptPath;
                            Title = path;

                            if (_console != null)
                            {
                                _console.Close();
                            }

                            var procStartInfo = new ProcessStartInfo("cmd");
                            var app = (App)Application.Current;
                            procStartInfo.WorkingDirectory = app.AppSettings.AdbDirectory;
                            _console = new ConsoleProcess(procStartInfo);
                            _console.Start();

                            var script = File.ReadAllLines(path);
                            var api = new Api(_console, script);
                            var output = new Subject<string>();
                            var errors = new Subject<string>();

                            api.Console.OnOutputReceived(output.OnNext);
                            api.Console.OnErrorReceived(errors.OnNext);

                            output.Merge(errors).Subscribe(str => System.Diagnostics.Trace.Write(str));

                            UiScriptCommander.Api = api;
                        });
                    }
                };

            var adbDirectory = _app.AppSettings.AdbDirectory;
            if (string.IsNullOrWhiteSpace(adbDirectory))
            {
                SetAdbPath();
            }
        }
开发者ID:ru-sh,项目名称:ScriptManager,代码行数:52,代码来源:Main.xaml.cs


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