Esempio n. 1
0
        public IDisposable ProcessEntity <T>(IReactToDataSystem <T> system, IEntity entity)
        {
            var hasEntityPredicate = system.TargetGroup is IHasPredicate;
            var reactObservable    = system.ReactToData(entity);

            if (!hasEntityPredicate)
            {
                return(reactObservable.Subscribe(x => system.Execute(entity, x)));
            }

            var groupPredicate = system.TargetGroup as IHasPredicate;

            return(reactObservable
                   .Where(x => groupPredicate.CanProcessEntity(entity))
                   .Subscribe(x => system.Execute(entity, x)));
        }
Esempio n. 2
0
        public SubscriptionToken ProcessEntity <T>(IReactToDataSystem <T> system, IEntity entity)
        {
            var hasEntityPredicate = system.TargetGroup.TargettedEntities != null;
            var subscription       = system.ReactToEntity(entity)
                                     .Subscribe(x =>
            {
                if (hasEntityPredicate)
                {
                    if (system.TargetGroup.TargettedEntities(entity))
                    {
                        system.Execute(entity, x);
                    }
                    return;
                }

                system.Execute(entity, x);
            });

            return(new SubscriptionToken(entity, subscription));
        }
        public SubscriptionToken ProcessEntity <T>(IReactToDataSystem <T> system, IEntity entity)
        {
            var hasEntityPredicate = system.TargetGroup is IHasPredicate;
            var subscription       = system.ReactToData(entity)
                                     .Subscribe(x =>
            {
                if (hasEntityPredicate)
                {
                    var groupPredicate = system.TargetGroup as IHasPredicate;
                    if (groupPredicate.CanProcessEntity(entity))
                    {
                        system.Execute(entity, x);
                    }
                    return;
                }

                system.Execute(entity, x);
            });

            return(new SubscriptionToken(entity, subscription));
        }