public void Waiting(IActiveState state)
        {
            if (ShouldNotifyDistributor())
            {
                bus.Send(new WorkerThreadAvailableCommand
                             {
                                 Identifier = identifier,
                                 InboxWorkQueueUri = bus.Configuration.Inbox.WorkQueue.Uri.ToString(),
                                 DateSent = DateTime.Now
                             },
                         bus.Configuration.Worker.DistributorControlInboxWorkQueue);

                if (log.IsVerboseEnabled)
                {
                    log.Verbose(string.Format(ESBResources.DebugWorkerAvailable,
                                              identifier,
                                              bus.Configuration.Inbox.WorkQueue.Uri,
                                              bus.Configuration.Worker.DistributorControlInboxWorkQueue.Uri));
                }

                nextNotificationDate = DateTime.Now.AddSeconds(bus.Configuration.Worker.ThreadAvailableNotificationIntervalSeconds);
            }

            threadActivity.Waiting(state);
        }
Esempio n. 2
0
        public void Waiting(IActiveState state)
        {
            if (ShouldNotifyDistributor())
            {
                bus.Send(new WorkerThreadAvailableCommand
                {
                    Identifier        = identifier,
                    InboxWorkQueueUri = bus.Configuration.Inbox.WorkQueue.Uri.ToString(),
                    DateSent          = DateTime.Now
                },
                         bus.Configuration.Worker.DistributorControlInboxWorkQueue);

                if (log.IsVerboseEnabled)
                {
                    log.Verbose(string.Format(ESBResources.DebugWorkerAvailable,
                                              identifier,
                                              bus.Configuration.Inbox.WorkQueue.Uri,
                                              bus.Configuration.Worker.DistributorControlInboxWorkQueue.Uri));
                }

                nextNotificationDate = DateTime.Now.AddSeconds(bus.Configuration.Worker.ThreadAvailableNotificationIntervalSeconds);
            }

            threadActivity.Waiting(state);
        }
        public virtual void Execute(IActiveState state)
        {
            var messagePipeline = bus.Configuration.PipelineFactory.GetPipeline <TMessagePipeline>(bus);

            try
            {
                messagePipeline.State.Replace(StateKeys.Working, false);
                messagePipeline.State.Replace(StateKeys.ActiveState, state);

                messagePipeline.Execute();

                if (messagePipeline.State.Get <bool>(StateKeys.Working))
                {
                    bus.Events.OnThreadWorking(this, new ThreadStateEventArgs(typeof(TMessagePipeline)));

                    threadActivity.Working();
                }
                else
                {
                    bus.Events.OnThreadWaiting(this, new ThreadStateEventArgs(typeof(TMessagePipeline)));

                    threadActivity.Waiting(state);
                }
            }
            finally
            {
                bus.Configuration.PipelineFactory.ReleasePipeline(messagePipeline);
            }
        }
Esempio n. 4
0
 protected virtual void Awake()
 {
     _identifier         = UniqueIdentifier.Generate();
     ActiveState         = _activeState as IActiveState;
     InteractableFilters =
         _interactableFilters.ConvertAll(mono => mono as IMonoBehaviourFilter);
 }
Esempio n. 5
0
 public BaseMenu(SpriteBatch spriteBatch, IActiveState parent, string defaultFont, Size screenSize, Vector2 choiceOffset)
 {
     SpriteBatch        = spriteBatch;
     Parentmenu         = parent;
     SelectedChoiceFont = DefaultFont = Common.str2Font(defaultFont);
     TextureDrawRect    = new Rectangle(0, 0, screenSize.Width, screenSize.Height);
     ChoiceOffset       = choiceOffset;
 }
Esempio n. 6
0
            public void Start()
            {
                if (ActiveState == null)
                {
                    ActiveState = _activeState as IActiveState;
                }

                Assert.IsNotNull(ActiveState);
            }
Esempio n. 7
0
        protected virtual void Awake()
        {
            ActiveState = _activeState as IActiveState;
            Assert.IsNotNull(ActiveState);
            Assert.IsNotNull(_target);
            _material = _target.material;

            SetMaterialColor(_lastActiveValue ? _activeColor : _normalColor);
        }
        protected ResultState(IState parentState, IResultBuilder <T> resultBuilder, IActiveState activeState,
                              Creator <IResultAttributeBuilder> createAttributeBuilder, Creator <IAttributeState, IState, IResultAttributeBuilder> createAttributeState)
        {
            _parentState            = parentState;
            _resultBuilder          = resultBuilder;
            _activeState            = activeState;
            _createAttributeBuilder = createAttributeBuilder;
            _createAttributeState   = createAttributeState;

            Valid = true;
        }
Esempio n. 9
0
            private void ExecuteActions(IActiveState <TExec> state)
            {
                while (HasActions)
                {
                    if (state.HasOutcome && state.HasFailed)
                    {
                        state.ExecuteFailureAction();
                        return;
                    }
                    else if (state.HasException)
                    {
                        state.HandleException();
                        return;
                    }

                    if (!actions.TryDequeue(out var action))
                    {
                        continue;
                    }
                    state.BackUp(action);

                    if (action.hasDefaultValue && state.OutcomeMustDefault)
                    {
                        state.Outcome(action.defaultValue);
                    }
                    else
                    {
                        try
                        {
                            if (action.IsConsumer)
                            {
                                action.AsConsumer().Invoke(state.Outcome <TExec>());
                            }
                            else if (action.IsFunction)
                            {
                                if (action.HasNestedCompletes)
                                {
                                    ((ICompletes <TExec>)action.AsFunction().Invoke(state.Outcome <TExec>()))
                                    .AndThenConsume(value => action.NestedCompletes.With(value));
                                }
                                else
                                {
                                    state.Outcome(action.AsFunction().Invoke(state.Outcome <TExec>()));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            state.HandleException(ex);
                            break;
                        }
                    }
                }
            }
        public HandlerContext(IServiceBus bus, TransportMessage transportMessage, T message, IActiveState activeState)
        {
            Guard.AgainstNull(bus, "bus");
            Guard.AgainstNull(transportMessage, "transportMessage");
            Guard.AgainstNull(message, "message");
            Guard.AgainstNull(activeState, "activeState");

            Bus = bus;
            TransportMessage = transportMessage;
            Message          = message;
            ActiveState      = activeState;
        }
Esempio n. 11
0
        public CreditsMenu(IActiveState parent, IEngine engine, string background, string creditFont, string creditTitleFont)
        {
            Parent    = parent;
            Engine    = engine;
            Font      = Common.str2Font(creditFont);
            FontTitle = Common.str2Font(creditTitleFont);

            if (background != null)
            {
                BGTexture = Common.str2Tex(background);
            }
        }
        public CreditsMenu2(IActiveState parent, SpriteBatch spriteBatch, Rectangle screenArea, string background, string creditFont, string creditTitleFont)
        {
            Parent      = parent;
            Font        = Common.str2Font(creditFont);
            FontTitle   = Common.str2Font(creditTitleFont);
            ScreenArea  = screenArea;
            SpriteBatch = spriteBatch;

            if (background != null)
            {
                BGTexture = Common.str2Tex(background);
            }
        }
Esempio n. 13
0
 internal void Execute(IActiveState <TExec> state)
 {
     while (true)
     {
         if (accessible.CompareAndSet(false, true))
         {
             readyToExecute.Set(true);
             ExecuteActions(state);
             accessible.Set(false);
             break;
         }
     }
 }
Esempio n. 14
0
 protected internal BasicCompletes(IActiveState <T> state, T outcome, bool succeeded)
 {
     this.state = state;
     if (succeeded)
     {
         this.state.CompletedWith(outcome);
     }
     else
     {
         this.state.FailedValue(Optional.Of(outcome));
         this.state.Failed();
     }
 }
Esempio n. 15
0
        public ReaderState(IActiveState activeState, IResultNodeCallback resultNodeCallback, IResultNode rootResultNode, IResultMetadata resultMetadata, IScanContext scanContext,
                           Creator <IResultNodeBuilder> createResultNodeBuilder, Creator <IResultNodeState, IState, IResultNodeBuilder> createResultNodeReaderState)
        {
            _activeState                 = activeState;
            _resultNodeCallback          = resultNodeCallback;
            _rootResultNode              = rootResultNode;
            _resultMetadata              = resultMetadata;
            _scanContext                 = scanContext;
            _createResultNodeBuilder     = createResultNodeBuilder;
            _createResultNodeReaderState = createResultNodeReaderState;

            _scanContext.Results = rootResultNode;

            Valid = true;

            _activeState.ChangeState(this);
        }
Esempio n. 16
0
        public virtual void Execute(IActiveState state)
        {
            var availableWorker = _bus.Configuration.WorkerAvailabilityManager.GetAvailableWorker();

            if (_bus.Configuration.Inbox.Distribute && availableWorker == null)
            {
                _threadActivity.Waiting(state);

                return;
            }

            var messagePipeline = availableWorker == null
                                      ? _bus.Configuration.PipelineFactory.GetPipeline<InboxMessagePipeline>(_bus)
                                      : _bus.Configuration.PipelineFactory.GetPipeline<DistributorPipeline>(_bus);

            try
            {
                messagePipeline.State.SetAvailableWorker(availableWorker);
                messagePipeline.State.ResetWorking();
                messagePipeline.State.SetActiveState(state);

                if (!state.Active)
                {
                    return;
                }

                messagePipeline.Execute();

                if (messagePipeline.State.Get<bool>(StateKeys.Working))
                {
                    _bus.Events.OnThreadWorking(this, new ThreadStateEventArgs(typeof(InboxMessagePipeline)));

                    _threadActivity.Working();
                }
                else
                {
                    _bus.Events.OnThreadWaiting(this, new ThreadStateEventArgs(typeof(InboxMessagePipeline)));

                    _threadActivity.Waiting(state);
                }
            }
            finally
            {
                _bus.Configuration.PipelineFactory.ReleasePipeline(messagePipeline);
            }
        }
        public void Execute(IActiveState state)
        {
            if (!ShouldProcessDeferred())
            {
                ThreadSleep.While(1000, state);

                return;
            }

            lock (_messageDeferredLock)
            {
                _messageDeferred = false;
            }

            var pipeline = (DeferredMessagePipeline)_bus.Configuration.PipelineFactory.GetPipeline<DeferredMessagePipeline>(_bus);

            pipeline.State.SetCheckpointMessageId(_checkpointMessageId);
            pipeline.State.SetNextDeferredProcessDate(_nextDeferredProcessDate);
            pipeline.State.SetDeferredMessageReturned(false);

            pipeline.Execute();

            var nextDeferredProcessDate = pipeline.State.Get<DateTime>(StateKeys.NextDeferredProcessDate);

            if (_messageDeferred)
            {
                if (nextDeferredProcessDate < _nextDeferredProcessDate)
                {
                    _nextDeferredProcessDate = nextDeferredProcessDate;
                }
            }
            else
            {
                _nextDeferredProcessDate = nextDeferredProcessDate;
            }

            if (_checkpointMessageId != pipeline.State.Get<Guid>(StateKeys.CheckpointMessageId))
            {
                _checkpointMessageId = pipeline.State.Get<Guid>(StateKeys.CheckpointMessageId);

                return;
            }

            _checkpointMessageId = Guid.Empty;
        }
Esempio n. 18
0
        public Credits(IActiveState parent)
        {
            Parent = parent;

            Font      = Common.str2Font("Credit");
            FontTitle = Common.str2Font("CreditTitle");
            AllCredits.Add(new Credit(true, "Invaders XNA"));
            AllCredits.Add(new Credit(true, "Created on August 11th 2011 (single sit-through)"));
            AllCredits.Add(new Credit(true, ""));
            AllCredits.Add(new Credit(true, ""));
            AllCredits.Add(new Credit(true, "Programming & Design"));
            AllCredits.Add(new Credit(false, "[email protected]*l*o v@o@n R@nz0vv"));
            AllCredits.Add(new Credit(true, ""));
            AllCredits.Add(new Credit(true, "Audio"));
            AllCredits.Add(new Credit(false, "sandyrb (www.freesoundproject.org) - Impact sound."));
            AllCredits.Add(new Credit(false, "grunz (www.freesound.org) - level up sound"));

            AllCredits.Add(new Credit(true, ""));
            AllCredits.Add(new Credit(true, "Graphics"));
            AllCredits.Add(new Credit(false, "ac3raven (www.opengameart.org) - Space Backgrounds"));
            AllCredits.Add(new Credit(false, "Lamoot (www.opengameart.org) - Player sprite"));
            AllCredits.Add(new Credit(false, "CruzR (www.opengameart.org) - Laser sprites"));
            AllCredits.Add(new Credit(false, "[email protected]*l*o v@o@n R@nz0vv - Blocks"));
            AllCredits.Add(new Credit(true, ""));
            AllCredits.Add(new Credit(true, "Special Thanks & Tools"));
            AllCredits.Add(new Credit(false, "The Gimp"));

            int y = Engine.Instance.Height;

            foreach (Credit credit in AllCredits)
            {
                SpriteFont measureFont;
                if (credit.IsTitle)
                {
                    measureFont = FontTitle;
                }
                else
                {
                    measureFont = Font;
                }
                credit.Location = Common.CenterStringX(measureFont, credit.Person, Engine.Instance.Width, y);
                y += (int)measureFont.MeasureString(Common.MeasureString).Y;
            }
        }
Esempio n. 19
0
        public virtual void Execute(IActiveState state)
        {
            var availableWorker = bus.Configuration.WorkerAvailabilityManager.GetAvailableWorker();

            if (bus.Configuration.Inbox.Distribute && availableWorker == null)
            {
                threadActivity.Waiting(state);

                return;
            }

            var messagePipeline = availableWorker == null
                                      ? bus.Configuration.PipelineFactory.GetPipeline <InboxMessagePipeline>(bus)
                                      : bus.Configuration.PipelineFactory.GetPipeline <DistributorPipeline>(bus);

            try
            {
                messagePipeline.State.Replace(StateKeys.AvailableWorker, availableWorker);
                messagePipeline.State.Replace(StateKeys.Working, false);
                messagePipeline.State.Replace(StateKeys.ActiveState, state);

                messagePipeline.Execute();

                if (messagePipeline.State.Get <bool>(StateKeys.Working))
                {
                    bus.Events.OnThreadWorking(this, new ThreadStateEventArgs(typeof(InboxMessagePipeline)));

                    threadActivity.Working();
                }
                else
                {
                    bus.Events.OnThreadWaiting(this, new ThreadStateEventArgs(typeof(InboxMessagePipeline)));

                    threadActivity.Waiting(state);
                }
            }
            finally
            {
                bus.Configuration.PipelineFactory.ReleasePipeline(messagePipeline);
            }
        }
Esempio n. 20
0
 public void InjectActiveState(IActiveState activeState)
 {
     _activeState = activeState as MonoBehaviour;
     ActiveState  = activeState;
 }
Esempio n. 21
0
 public void RegisterWithExecution(Action <TBActSt> action, TimeSpan timeout, IActiveState <TBActSt> state)
 => executables.RegisterWithExecution(action, timeout, state);
Esempio n. 22
0
 protected internal BasicCompletes(IActiveState <T> state, T outcome)
 {
     this.state = state;
     this.state.Outcome(outcome);
 }
Esempio n. 23
0
 void IProcessor.Execute(IActiveState state)
 {
     Execute(state);
 }
 public void InjectAllActiveStateUnityEventWrapper(IActiveState activeState)
 {
     InjectActiveState(activeState);
 }
Esempio n. 25
0
 internal void RegisterWithExecution(Action <TExec> action, TimeSpan timeout, IActiveState <TExec> state)
 {
     while (true)
     {
         if (accessible.CompareAndSet(false, true))
         {
             actions.Enqueue(action);
             if (IsReadyToExecute)
             {
                 ExecuteActions(state);
             }
             else
             {
                 state.StartTimer(timeout);
             }
             accessible.Set(false);
             break;
         }
     }
 }
Esempio n. 26
0
 public void InjectAllActiveStateSelector(IActiveState activeState)
 {
     InjectActiveState(activeState);
 }
Esempio n. 27
0
 protected internal BasicCompletes(IActiveState <T> state)
 {
     this.state = state;
 }
 public static void SetActiveState(this State<ObservablePipeline> state, IActiveState activeState)
 {
     state.Add(StateKeys.ActiveState, activeState);
 }
Esempio n. 29
0
 public BaseMenuBarred(IEngine engine, IActiveState parent)
 {
     IEngine    = engine;
     Parentmenu = parent;
 }
        public ActiveTimeRangeObserver(IActiveState state)
        {
            Guard.AgainstNull(state, "state");

            this.state = state;
        }
 void IProcessor.Execute(IActiveState state)
 {
     Execute(state);
 }
Esempio n. 32
0
 protected virtual void Awake()
 {
     ActiveState = _activeState as IActiveState;
 }
Esempio n. 33
0
 public void InjectAllActiveStateTracker(IActiveState activeState)
 {
     InjectActiveState(activeState);
 }
Esempio n. 34
0
        public ResultNodeState(IState parentState, IResultNodeBuilder resultNodeBuilder, IActiveState activeState,
                               Creator <IResultAttributeBuilder> createAttributeBuilder,
                               Creator <IAttributeState, IState, IResultAttributeBuilder> createAttributeState)

            : base(parentState, resultNodeBuilder, activeState, createAttributeBuilder, createAttributeState)
        {
        }
Esempio n. 35
0
        public AttributeState(IState parentState, IResultAttributeBuilder attributeBuilder, IActiveState activeState,
                              Creator <IResultAttributeBuilder> createAttributeBuilder,
                              Creator <IAttributeState, IState, IResultAttributeBuilder> createChildAttributeState)

            : base(parentState, attributeBuilder, activeState, createAttributeBuilder, createChildAttributeState)
        {
            _attributeBuilder = attributeBuilder;
        }