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


C# IObservable.OfType方法代码示例

本文整理汇总了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);
     });
 }
开发者ID:kb10uy,项目名称:KbtterCore,代码行数:38,代码来源:Streaming.cs

示例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);
        }
开发者ID:agross,项目名称:mpc-deleter,代码行数:8,代码来源:ArchiveCurrentFileHandler.cs

示例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>();
 }
开发者ID:rho24,项目名称:Golf,代码行数:8,代码来源:ViewController.cs

示例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));
        }
开发者ID:agross,项目名称:mpc-deleter,代码行数:9,代码来源:DeleteCurrentFileHandler.cs

示例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)));
        }
开发者ID:agross,项目名称:mpc-deleter,代码行数:10,代码来源:AdvanceToNextFileHandler.cs

示例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)));
        }
开发者ID:agross,项目名称:mpc-deleter,代码行数:10,代码来源:FastForwardHandler.cs

示例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));
        }
开发者ID:veggielane,项目名称:CasualScience.Dynamixel,代码行数:16,代码来源:DynamixelBus.cs

示例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);
        }
开发者ID:rho24,项目名称:Golf,代码行数:20,代码来源:PhysicsEngine.cs

示例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);
        }
开发者ID:SvenEV,项目名称:OrangeBugReloaded,代码行数:20,代码来源:EntityInfo.cs

示例10: SurfaceManager

 public SurfaceManager(IObservable<IGameEvent> events, IEventTriggerer eventTriggerer)
 {
     _eventTriggerer = eventTriggerer;
     events.OfType<AddSurfaceRequest>().Subscribe(AddSurface);
     events.OfType<PositionChanged>().Subscribe(PositionChanged);
 }
开发者ID:rho24,项目名称:Golf,代码行数:6,代码来源:SurfaceManager.cs

示例11: BarrierManager

        public BarrierManager(IObservable<IGameEvent> events )
        {
            _barriers = new List<IBarrier>();

            events.OfType<AddBarrierRequest>().Subscribe(AddBarrier);
        }
开发者ID:rho24,项目名称:Golf,代码行数:6,代码来源:BarrierManager.cs


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