本文整理汇总了C#中IObservable.Where方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.Where方法的具体用法?C# IObservable.Where怎么用?C# IObservable.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObservable
的用法示例。
在下文中一共展示了IObservable.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public IObservable<object> Execute(IObservable<Tuple<string, string>> stream)
{
var faces = stream.Where(t => t.Item1 == "faces").Select(t => t.Item2);
var height = stream.Where(t => t.Item1 == "height").Select(t => double.Parse(t.Item2));
return faces.CombineLatest(height, (f, h) => h > 2.0).Select(b => b.ToString());
}
示例2: Execute
public IObservable<object> Execute(IObservable<Tuple<string, string>> stream)
{
var first = stream.Where(t => t.Item1 == "firstname").Select(t => t.Item2);
var last = stream.Where(t => t.Item1 == "lastname").Select(t => t.Item2);
var zipped = first.Zip(last, (f, b) => f + " " + b);
return zipped;
}
示例3: Execute
public IObservable<object> Execute(IObservable<Tuple<string, string>> stream)
{
var foo = stream.Where(t => t.Item1 == "foo").Select(t => t.Item2);
var bar = stream.Where(t => t.Item1 == "bar").Select(t => t.Item2);
return foo.Zip(bar, (f, b) => f + ":" + b)
.Select(v => v + " is " + v.Length + " chars long.");
}
示例4: ActivityViewModel
public ActivityViewModel(IObservable<ApplicationActivityMessage> activityMessages)
{
var busyStream1 = activityMessages
.Where(msg => msg.GettingBusy)
.ObserveOnDispatcher().Subscribe(onGettingBusy);
var busyStream2 = activityMessages
.Where(msg => msg.GettingCalm)
.ObserveOnDispatcher().Subscribe(onGettingCalm);
disposer.Add(busyStream1, busyStream2);
}
示例5: ActivityContainer
public ActivityContainer(IObservable<ActivityMsg> activityMessages)
{
var busyStream1 = activityMessages
.Where(msg => msg.GettingBusy)
.ObserveOnDispatcher().Subscribe(OnGettingBusy);
var busyStream2 = activityMessages
.Where(msg => msg.GettingCalm)
.ObserveOnDispatcher().Subscribe(OnGettingCalm);
disposer.Add(busyStream1, busyStream2);
}
示例6: Execute
public IObservable<object> Execute(IObservable<Tuple<string, string>> stream)
{
var faces = stream
.Where(t => t.Item1 == "faces")
.Select(t => t.Item2)
.Where(s => s.Length > 2);
var height = stream.Where(t => t.Item1 == "height").Select(t => double.Parse(t.Item2));
return faces.Zip(height, (f, h) => f + "..." + h);
}
示例7: Execute
public IObservable<object> Execute(IObservable<Tuple<string, string>> stream)
{
var faces = stream
.Where(t => t.Item1 == "faces")
.Select(t => t.Item2)
.Where(s => !s.Equals("[]"));
var navdata = stream
.Where(t => t.Item1 == "navdata")
.Select(t => t.Item2);
return faces.CombineLatest(navdata, (f, n) => "Use " + f + " with " + n);
}
示例8: Execute
public IObservable<object> Execute(IObservable<Tuple<string, string>> stream)
{
return stream
.Where(t => t.Item1 == "<default>")
.Select(t => t.Item2)
.Select(v => v + " is " + v.Length + " chars long.");
}
示例9: FilterFileSystemEntities
public override IObservable<FileSystemEntity> FilterFileSystemEntities(IObservable<FileSystemEntity> source)
{
return source.Where(x =>
{
return x.CreationTime < _dateTime;
});
}
示例10: computePlayerData
public static IEnumerable<IObservable<PlayerData>> computePlayerData(IObservable<SensorData> src)
{
var scheduler = new EventLoopScheduler();
return
MetaData
.PLAYER_MAP
.Select((KeyValuePair<string, List<int>> keyValue, int index) =>
{
var pt = PerformanceTest.ptArray[index];
var sensorList = keyValue.Value; //The list of sensors attached to this player
var sensorStreamList =
sensorList.Select((int sensor_id) =>
{
return src//.ObserveOn(scheduler)
.Where(ss => ss.sensor_id == sensor_id)
.Once(MetaData.getDefaultSensorDataWithSensorID(sensor_id));
});
return
Observable
.Zip(sensorStreamList)
//If AvgProcessorStatus==true, then compute performance metrics for AverageProcessor.
.DoIf(() => PerformanceTest.AvgProcessorStatus, d => pt.recordTime())
.Select(returnPlayerData)
.Where(data => !String.IsNullOrEmpty(data.player_name))
//compute time taken to produce a PlayerData sample from list of updated sensor values.
.DoIf(() => PerformanceTest.AvgProcessorStatus, d => pt.computeMetrics());
});
}
示例11: Main
static void Main(string[] args)
{
_listener.Prefixes.Add("http://" + Environment.MachineName + ":9000/");
_listener.Start();
Console.WriteLine("Listening ...");
while (true)
{
HttpListenerContext context = _listener.GetContext();
_request = context.Request;
HttpListenerResponse response = context.Response;
_sb = new StringBuilder("<HTML>\n<HEAD>\n<TITLE>");
_sb.Append("Trace 2 Html");
_sb.Append("</TITLE>\n</HEAD>\n<BODY>\n");
_sb.Append("<pre style=\"font-family:Consolas; font-size: 10pt; width: 5000px;\">");
_playback = new Playback();
_playback.AddEtlFiles(LocalTrace);
_all = _playback.GetObservable<TracedEvent>();
if (_request.QueryString["process"] != null)
{
_processFilter = _request.QueryString["process"];
_all = _all.Where(e => e.Message.StartsWith(_processFilter));
}
else
{
_processFilter = null;
}
if (_request.QueryString["after"] != null)
{
var after = int.Parse(_request.QueryString.Get("after"));
AllHistory(after);
}
else if (_request.QueryString["afterReceive"] != null)
{
string messageId = _request.QueryString.Get("afterReceive");
AfterReceive(messageId);
}
else if (_request.QueryString["beforeSend"] != null)
{
string messageId = _request.QueryString.Get("beforeSend");
BeforeSend(messageId);
}
else
{
AllHistory(0);
}
_sb.Append("</BODY></HTML>");
byte[] buffer = Encoding.UTF8.GetBytes(_sb.ToString());
response.ContentLength64 = buffer.Length;
response.OutputStream.Write(buffer, 0, buffer.Length);
response.OutputStream.Close();
_playback.Dispose();
}
}
示例12: PreviewViewModel
public PreviewViewModel(IObservable<NewHtmlMsg> newHtmlMessages, IDispatchServices svc, IPublisher publisher)
{
_publisher = publisher;
newHtmlMessages
.Where(msg => _browserCompletedLoad)
.ObserveOn(svc)
.Subscribe(NextHtml);
}
示例13: ViewController
public ViewController(IObservable<IGameEvent> events)
{
events.Where(e => e is Tick || e is PositionChanged).ObserveOnDispatcher().Subscribe(e => UpdatePositions());
events.OfType<SurfaceAdded>().ObserveOnDispatcher().Subscribe(OnSurfaceAdded);
events.OfType<GameObjectAdded>().ObserveOnDispatcher().Subscribe(OnGameObjectAdded);
Views = new ObservableCollection<UserControl>();
_viewModels = new List<ViewModelBase>();
}
示例14: LongPressAsObservable
private static IObservable<KeyAndState> LongPressAsObservable(IObservable<KeyAndState> press, IObservable<KeyAndState> release, TimeSpan delay, IScheduler scheduler)
{
return press.SelectMany(
pressed =>
Observable
.Return(pressed)
.Delay(delay, scheduler)
.TakeUntil(release.Where(released => pressed.Key == released.Key)));
}
示例15: SetUp
public IDisposable SetUp(IObservable<string> source)
{
return source
.Where(Matches)
.DelayBetweenValues(TimeSpan.FromSeconds(5),
TaskPoolScheduler.Default,
() => RxMessageBrokerMinimod.Default.Send(new Log("You pressed the 'Delete current file' key in quick succession. " +
"This key press will be ignored.")))
.Subscribe(x => Handle());
}