本文整理汇总了C#中IObservable.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.OfType方法的具体用法?C# IObservable.OfType怎么用?C# IObservable.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObservable
的用法示例。
在下文中一共展示了IObservable.OfType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartStreaming
/// <summary>
/// Streaming APIを初期化して、ストリーミングを開始します。
/// </summary>
public void StartStreaming()
{
Service.IncludeEntities = true;
Service.IncludeRetweets = true;
Stream = Service.StreamUser();
//各種
Stream.OfType<TwitterUserStreamStatus>().Subscribe((p) =>
{
if (StreamingStatus != null) StreamingStatus(p);
});
Stream.OfType<TwitterUserStreamEvent>().Subscribe((p) =>
{
if (StreamingEvent != null) StreamingEvent(p);
});
Stream.OfType<TwitterUserStreamUserEvent>().Subscribe((p) =>
{
if (StreamingUserEvent != null) StreamingUserEvent(p);
});
Stream.OfType<TwitterUserStreamDirectMessage>().Subscribe((p) =>
{
if (StreamingDirectMessage != null) StreamingDirectMessage(p);
});
Stream.OfType<TwitterUserStreamFriends>().Subscribe((p) =>
{
if (StreamingFriends != null) StreamingFriends(p);
});
Stream.OfType<TwitterUserStreamDeleteStatus>().Subscribe((p) =>
{
if (StreamingDeleteStatus != null) StreamingDeleteStatus(p);
});
Stream.OfType<TwitterUserStreamDeleteDirectMessage>().Subscribe((p) =>
{
if (StreamingDeleteDirectMessage != null) StreamingDeleteDirectMessage(p);
});
}
示例2: ArchiveCurrentFile
static IObservable<Params> ArchiveCurrentFile(IObservable<object> stream)
{
var archive = stream.OfType<ArchiveCurrentFile>();
var file = stream.OfType<CurrentFile>();
return file.CombineLatest(archive, (f, arch) => new Params(f, arch))
.DistinctUntilChanged(data => data.Command);
}
示例3: 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>();
}
示例4: DeleteCurrentFile
static IObservable<Params> DeleteCurrentFile(IObservable<object> stream)
{
var delete = stream.OfType<DeleteCurrentFile>();
var file = stream.OfType<CurrentFile>();
return file.CombineLatest(delete, (f, d) => new { File = f, Command = d })
.DistinctUntilChanged(data => data.Command)
.Select(x => new Params(x.File, x.Command));
}
示例5: AdvanceToNextFile
static IObservable<SendMessage> AdvanceToNextFile(IObservable<object> stream)
{
var advance = stream.OfType<AdvanceToNextFile>();
var file = stream.OfType<CurrentFile>();
return file.CombineLatest(advance, (f, a) => new { File = f, Command = a })
.DistinctUntilChanged(data => data.Command)
.Select(x => new SendMessage(NativeConstants.CMD_SETPOSITION,
OneSecondBeforeEnd(x.File)));
}
示例6: FastForwardCurrentFilePosition
static IObservable<SendMessage> FastForwardCurrentFilePosition(IObservable<object> stream)
{
var ffw = stream.OfType<FastForward>();
var file = stream.OfType<CurrentFile>();
return file.CombineLatest(ffw, (f, ff) => new { File = f, Command = ff })
.DistinctUntilChanged(data => data.Command)
.Select(x => new SendMessage(NativeConstants.CMD_JUMPOFNSECONDS,
TenPercentOfLength(x.File)));
}
示例7: DynamixelBus
//private readonly Dictionary<byte, DynamixelDevice> _dynamixelDevices = new Dictionary<byte, DynamixelDevice>();
//public ReadOnlyDictionary<byte, DynamixelDevice> Devices
//{
// get { return new ReadOnlyDictionary<byte, DynamixelDevice>(_dynamixelDevices); }
//}
public DynamixelBus(string portName, int baudRate)
{
_port = new DynamixelPort("COM3", 1000000);
_subject = new Subject<IPacket>();
Packets = _subject.AsObservable();
_port.StatusPacketReceived += Add;
Packets.OfType<InstructionPacket>().Subscribe(p => _port.Write(p));
}
示例8: PhysicsEngine
public PhysicsEngine(IObservable<IGameEvent> events, IEventTriggerer eventTriggerer, IBarriers barriers)
{
_eventTriggerer = eventTriggerer;
_barriers = barriers;
events.OfType<AddGameObjectRequest>()
.Subscribe(AddGameObject);
events.OfType<PositionChangeRequest>()
.Subscribe(ChangePosition);
events.OfType<ApplyImpulseRequest>()
.Subscribe(ApplyImpulse);
events.OfType<AddForceRequest>()
.Subscribe(AddForce);
events.OfType<RemoveForceRequest>()
.Subscribe(RemoveForce);
}
示例9: EntityInfo
public EntityInfo(Entity entity, Point position, IObservable<IGameEvent> eventStream)
{
Entity = entity;
SourcePosition = TargetPosition = CurrentPosition = position.ToVector2();
_moveSubscription = eventStream
.OfType<EntityMoveEvent>()
.Where(e => e.SourcePosition.ToVector2() == TargetPosition)
.Subscribe(OnEntityMoved);
_changeSubscription = eventStream
.OfType<EntityChangeEvent>()
.Where(e => e.Position.ToVector2() == TargetPosition)
.Subscribe(OnEntityChanged);
_despawnSubscription = eventStream
.OfType<EntityDespawnEvent>()
.Where(e => e.Position.ToVector2() == TargetPosition)
.Subscribe(OnDespawn);
}
示例10: SurfaceManager
public SurfaceManager(IObservable<IGameEvent> events, IEventTriggerer eventTriggerer)
{
_eventTriggerer = eventTriggerer;
events.OfType<AddSurfaceRequest>().Subscribe(AddSurface);
events.OfType<PositionChanged>().Subscribe(PositionChanged);
}
示例11: BarrierManager
public BarrierManager(IObservable<IGameEvent> events )
{
_barriers = new List<IBarrier>();
events.OfType<AddBarrierRequest>().Subscribe(AddBarrier);
}