Register() public method

public Register ( string message, GameObject obj, bool isParallel = true ) : void
message string
obj GameObject
isParallel bool
return void
Exemplo n.º 1
0
        static async Task Main(string[] args)
        {
            var dispatcher = new Dispatcher();

            dispatcher.Register <SelectionVerb>("selection");
            dispatcher.Register <HitTasksVerb>("hittask");
            dispatcher.Register <SingletonKeeperVerb>("singleton");
            dispatcher.Register <MathsVerb>("maths");
            dispatcher.Register <TokenClientVerb>("token");
            dispatcher.Register <HttpClientVerb>("http");
            dispatcher.Register <RetryVerb>("retry");
            dispatcher.Register <CsvVerb>("csv");
            dispatcher.RegisterHelp();
            dispatcher.RegisterExit();
            if (args.Length > 0)
            {
                dispatcher.Process(args);
            }
            else
            {
                System.Console.WriteLine("Type 'help' to get help.");
                await dispatcher.ProcessAsync(true);

                System.Console.WriteLine("Bye!");
            }
        }
 /// <exception cref="System.Exception"/>
 protected override void ServiceInit(Configuration conf)
 {
     lock (this)
     {
         historyServiceEnabled = conf.GetBoolean(YarnConfiguration.ApplicationHistoryEnabled
                                                 , YarnConfiguration.DefaultApplicationHistoryEnabled);
         if (conf.Get(YarnConfiguration.ApplicationHistoryStore) == null || conf.Get(YarnConfiguration
                                                                                     .ApplicationHistoryStore).Length == 0 || conf.Get(YarnConfiguration.ApplicationHistoryStore
                                                                                                                                       ).Equals(typeof(NullApplicationHistoryStore).FullName))
         {
             historyServiceEnabled = false;
         }
         // Only create the services when the history service is enabled and not
         // using the null store, preventing wasting the system resources.
         if (historyServiceEnabled)
         {
             writer = CreateApplicationHistoryStore(conf);
             AddIfService(writer);
             dispatcher = CreateDispatcher(conf);
             dispatcher.Register(typeof(WritingHistoryEventType), new RMApplicationHistoryWriter.ForwardingEventHandler
                                     (this));
             AddIfService(dispatcher);
         }
         base.ServiceInit(conf);
     }
 }
Exemplo n.º 3
0
 private MessageStore(IHubContext context, Dispatcher dispatcher)
 {
     _context        = context;
     _store          = new Store();
     _store.Changed += StoreChanged;
     dispatcher.Register(_store.HandleAction);
 }
Exemplo n.º 4
0
        public static Func <ICommand, Task> Run(CancellationToken token, Subject <IEvent> eventSubject, Action <string> logger)
        {
            const string streamName       = "hamsters";
            var          commitLog        = new MessageVaultClientAdapter(new MemoryClient(), logger);
            var          dispatcher       = new Dispatcher <ICommand, Task>();
            var          eventHandlers    = new Dispatcher <IEvent, Task>();
            var          checkpointWriter = new CheckpointWriterAdapter(new MemoryCheckpointReaderWriter());
            var          repository       = new InMemoryStateRepository <HamsterState>();
            var          streamProcessor  = new StreamProcessor(commitLog, streamName, checkpointWriter, Serialization.Deserializer(), Console.WriteLine);

            var eventLog = commitLog.ToStreamPoster(Serialization.Serializer());

            dispatcher.Register <IHamsterCommand>(
                command => ApplicationService.Execute(
                    command,
                    id => repository.GetOrCreateAsync(id),
                    state => new HamsterAggregate(state),
                    aggregate => aggregate.Handle(command),
                    eventLog.ForStream(streamName)));

            eventHandlers.Register <IEvent>(@event => StateEventHandler.ForAsync(@event, repository));

            eventSubject.Subscribe(@event => eventHandlers.Dispatch(@event).Wait(token), () => { }, token);

            streamProcessor.Run(token, @event => eventSubject.OnNext(@event));

            return(dispatcher.Dispatch);

            return(Mixins.WaitForEventsPublished(dispatcher.Dispatch, eventSubject, logger));
        }
        public void CSharpFluxTests_Dispatcher_RaisesInvalidOperationIfDispatchingIsAlreadyInProgress()
        {
            //Given a callback is registered
            var dispatcher = new Dispatcher();

            var isDelegateCalled = false;
            var delegateMock     = new Action <Payload <TestActionTypes> >(c =>
            {
                // Verify the data from the Dispatch
                Assert.IsTrue(c.Data.Equals("Logging out..."));
                // Verify the exception is raised
                Assert.That(() => dispatcher.DispatchImplementation(Payload <TestActionTypes>
                                                                    .From(TestActionTypes.Login, "Logging in...")),
                            Throws.TypeOf <InvalidOperationException>());
                isDelegateCalled = true;
            });

            //When a callback is registered for the Action
            dispatcher.Register(delegateMock);

            //Then I should be able to dispatch Enum actions
            dispatcher.DispatchImplementation(Payload <TestActionTypes>
                                              .From(TestActionTypes.Logout, "Logging out..."));

            //Verify the callback was invoked
            Assert.IsTrue(isDelegateCalled);
        }
        public void CSharpFluxTests_Dispatcher_IsAbleToDispatchUsingStaticDispatch()
        {
            //Given a callback is registered
            var dispatcher = new Dispatcher();

            Dispatcher.RegisterDefaultDispatcher(dispatcher);

            var isDelegateCalled = false;
            var delegateMock     = new Action <Payload <TestActionTypes> >(c =>
            {
                // Verify the data from the Dispatch
                Assert.IsTrue(c.Data.Equals("Logging out..."));
                isDelegateCalled = true;
            });

            //When a callback is registered for the Action
            dispatcher.Register(delegateMock);

            //Then I should be able to dispatch Enum actions
            Dispatcher.Dispatch(Payload <TestActionTypes>
                                .From(TestActionTypes.Logout, "Logging out..."));

            //Verify the callback was invoked
            Assert.IsTrue(isDelegateCalled);
        }
Exemplo n.º 7
0
        public static void Register()
        {
            var node = Dispatcher.Register(Literal("teleport")
                                           .Then(Argument("position", Vector2ArgumentType.Instance)
                                                 .RequiresPlayer()
                                                 .Executes(context =>
            {
                var player   = context.Source.Player;
                var position = Vector2ArgumentType.GetValue(context, "position");
                player.TeleportAndNotify(position);
                return(1);
            })));

            Dispatcher.Register(Literal("tp")
                                .Redirect(node));

            Dispatcher.Register(Literal("back")
                                .RequiresPlayer()
                                .Executes(context =>
            {
                var player      = context.Source.Player;
                var oldPosition = ((IPlayerExtension)player).OldPosition;

                if (oldPosition != null)
                {
                    player.TeleportAndNotify((Vector2)oldPosition);
                }
                else
                {
                    player.SendMessageToPlayer("No previous position stored");
                }

                return(1);
            }));
        }
Exemplo n.º 8
0
 public void AddServiceDispatcher(IServiceDispatcher <ConnectionContext <C>, string> serviceDispatcher)
 {
     if (_started)
     {
         throw new Exception("Dispatchers should be all added before starting the server.");
     }
     _dispatcher.Register(serviceDispatcher);
 }
Exemplo n.º 9
0
 public static void Register()
 {
     Dispatcher.Register(Literal("respawn")
                         .Requires(source => source.Player != null && source.Player.respawnTimer > 0)
                         .Executes(context =>
     {
         NetMessage.SendData(12, -1, -1, null, context.Source.Player.whoAmI);
         return(1);
     }));
 }
            public HandlerCompositionRoot(string tenantId)
            {
                var connectionSettingsFactory = new ConventionTenantSqlConnectionSettingsFactory(tenantId);

                _dispatcher = new Dispatcher <object, IEnumerable <object> >();

                var connectionSettings = new
                {
                    Domain      = connectionSettingsFactory.GetSettings(),
                    Projections = connectionSettingsFactory.GetSettings("Projections")
                };

                _dispatcher.Register <ItemPurchased>(Handlers.Handle);

                _dispatcher.Register <SqlNonQueryCommand>(command =>
                {
                    return(Enumerable.Empty <object>());
                });
            }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Dispatcher dispatcher = Dispatcher.Instance;
            Store      store      = new Store();

            dispatcher.Register(store.HandleAction);
            Client cli1 = new Client("Bill", store);
            Client cli2 = new Client("Jing", store);

            cli1.CreateMessage("Hey jin, how are you");
            cli2.CreateMessage("Fine thanks !");

            Console.ReadLine();
        }
Exemplo n.º 12
0
 static void configureHandlers(Dispatcher dispatcher)
 {
     dispatcher.Register(new GetUsageHandler(dispatcher));
     dispatcher.Register(new CrawlHandler(_cache));
     dispatcher.Register(new CrawlFileTypesHandler());
     dispatcher.Register(new CreateHandler(getReferenceTypeResolver(), _keyPath));
     dispatcher.Register(new AddFileHandler(getTypesProvider));
     dispatcher.Register(new DeleteFileHandler(getTypesProvider));
     dispatcher.Register(new ReferenceHandler(getTypesProvider, _keyPath));
     dispatcher.Register(new DereferenceHandler(getTypesProvider, _keyPath));
     dispatcher.Register(new NewHandler(getFileTypeResolver(), getTypesProvider, _keyPath));
     dispatcher.Register(new RemoveFileHandler(getTypesProvider));
     dispatcher.Register(new SignatureFromPositionHandler(_cache));
     dispatcher.Register(new MembersFromUnknownSignatureHandler());
     dispatcher.Register(new GoToDefinitionHandler(_cache));
 }
Exemplo n.º 13
0
 public void Setup()
 {
     _handler = new FakeHandler();
     _execute = new Dispatcher();
     _execute.Register(_handler);
 }