本文整理汇总了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));
}
示例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();
}
}