Пример #1
0
 public static IObservable <VerocityInfo> Verocity(this IInputObservable io)
 {
     return(io.OnBegin.SelectMany(e =>
                                  Observable.Merge(Observable.Return(e), io.Any().TakeUntil(io.OnEnd.DelayFrame(1)))
                                  .TimeInterval()
                                  .Buffer(2, 1))
            .Where(ts => ts.Count > 1)
            .Select(ts => VerocityInfo.Create(ts[0], ts[1])));
 }
Пример #2
0
 public static IObservable <IList <VerocityInfo> > TakeLastVerocities(this IInputObservable io, int count)
 {
     return(io.TakeLastTimeIntervalBuffer(count).Select(timeEvents =>
     {
         var verocities = new List <VerocityInfo>();
         var prev = timeEvents.First();
         for (int i = 1; i < timeEvents.Count; i++)
         {
             var t = timeEvents[i];
             verocities.Add(VerocityInfo.Create(prev, t));
             prev = t;
         }
         return verocities;
     }));
 }