コード例 #1
0
 /// <inheritdoc />
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         EventDelegator.Unload();
     }
     base.Dispose(disposing);
 }
コード例 #2
0
        protected override void Dispose()
        {
            base.Dispose();

            EventDelegator.OnEvent -= OnWindowResize;

            EventDelegator.Dispose();
        }
コード例 #3
0
        protected override async Task OnAfterMountAsync()
        {
            await base.OnAfterMountAsync();

            EventDelegator.OnEvent += OnWindowResize;

            await EventDelegator.RegisterAsync(default(ElementReference), "resize", 200);
        }
コード例 #4
0
            public async Task ShouldNotThrowIfNoEventHandlerIsRegisteredInContainer()
            {
                var container            = new Container();
                var adapter              = new SimpleInjectorContainerAdapter(container);
                var eventHandlerResolver = new ContainerEventHandlerResolver(adapter);
                var delegator            = new EventDelegator(eventHandlerResolver);

                await delegator.SendAsync(new TestEvent1());
            }
コード例 #5
0
    void Awake()
    {
        EventDelegator.instance = this;

        GameManager.Instance.Game.NotifyStateStart            += triggerStateStart;
        GameManager.Instance.Game.NotifyStartOfTurn           += triggerStartOfTurn;
        GameManager.Instance.Game.NotifyPlayerActionPerformed += triggerPlayerActionPerformed;
        GameManager.Instance.Game.NotifyGameEnd += triggerGameEnd;
    }
コード例 #6
0
 public ArtificialIntelligenceSpa(IEventAgent eventAgent, string id)
     : base(eventAgent, id)
 {
     _strategy = new FirstStrategy(eventAgent);
     _eventDelegator = new EventDelegator();
     _eventProcessor = new SpaEventProcessor(_eventDelegator);
     _eventDelegator.ProductCreated = _strategy.ProductCompleted;
     _eventDelegator.InfanterySpotted = _strategy.EnemyContact;
     _eventDelegator.InfanteryReachedPosition = _strategy.ReachedPosition;
     _eventDelegator.UnitLost = _strategy.UnitLost;
 }
コード例 #7
0
ファイル: ZreBeacon.cs プロジェクト: torshy/DotNetZyre
        /// <summary>
        /// Create a new ZreBeacon, contained within the given context.
        /// </summary>
        /// <param name="context">the NetMQContext to contain this new socket</param>
        public ZreBeacon(NetMQContext context)
        {
            _actor = NetMQActor.Create(context, new Shim());

            EventHandler<NetMQActorEventArgs> onReceive = (sender, e) =>
                                                          _receiveEvent.Fire(this, new ZreBeaconEventArgs(this));

            _receiveEvent = new EventDelegator<ZreBeaconEventArgs>(
                () => _actor.ReceiveReady += onReceive,
                () => _actor.ReceiveReady -= onReceive);
        }
コード例 #8
0
 public LogoutCommandHandler(
     ILogger <LogoutCommandHandler> logger,
     IAccountService accountService,
     EventDelegator eventDelegator,
     ApplicationContext applicationContext)
 {
     _logger             = logger;
     _accountService     = accountService;
     _eventDelegator     = eventDelegator;
     _applicationContext = applicationContext;
 }
コード例 #9
0
ファイル: NetMQBeacon.cs プロジェクト: wangkai2014/netmq
        /// <summary>
        /// Create a new NetMQBeacon, contained within the given context.
        /// </summary>
        /// <param name="context">the NetMQContext to contain this new socket</param>
        public NetMQBeacon([NotNull] NetMQContext context)
        {
            m_actor = NetMQActor.Create(context, new Shim());

            EventHandler<NetMQActorEventArgs> onReceive = (sender, e) =>
                m_receiveEvent.Fire(this, new NetMQBeaconEventArgs(this));

            m_receiveEvent = new EventDelegator<NetMQBeaconEventArgs>(
                () => m_actor.ReceiveReady += onReceive,
                () => m_actor.ReceiveReady -= onReceive);
        }
コード例 #10
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            EventDelegator.Initialize();
            LoggerHelper.Initialize(this, "Amusoft Tooling");

            await ProjectMoverCommand.InitializeAsync(this);

            await Tooling.Features.ProjectRenamer.Commands.RenameProjectCommand.InitializeAsync(this);
        }
コード例 #11
0
 public App(IOptions <ApplicationSettings> config,
            ILogger <App> logger,
            EventDelegator eventDelegator,
            CommandDelegator commandDelegator,
            IServiceProvider serviceProvider,
            ApplicationContext applicationContext)
 {
     _logger             = logger;
     _eventDelegator     = eventDelegator;
     _commandDelegator   = commandDelegator;
     _serviceProvider    = serviceProvider;
     _applicationContext = applicationContext;
     _config             = config.Value;
 }
コード例 #12
0
        public WalletConnect(ClientMeta clientMeta, ITransport transport = null,
                             ICipher cipher   = null,
                             int?chainId      = 1,
                             string bridgeUrl = "https://bridge.walletconnect.org",
                             EventDelegator eventDelegator = null
                             )
        {
            if (eventDelegator == null)
            {
                eventDelegator = new EventDelegator();
            }

            this.Events = eventDelegator;

            this.ClientMetadata = clientMeta;
            this.ChainId        = chainId;

            if (bridgeUrl.StartsWith("https"))
            {
                bridgeUrl = bridgeUrl.Replace("https", "wss");
            }
            else if (bridgeUrl.StartsWith("http"))
            {
                bridgeUrl = bridgeUrl.Replace("http", "ws");
            }

            var topicGuid = Guid.NewGuid();

            _handshakeTopic = topicGuid.ToString();

            clientId = Guid.NewGuid().ToString();

            if (transport == null)
            {
                transport = new WebsocketTransport(eventDelegator);
            }

            this._bridgeUrl = bridgeUrl;
            this.Transport  = transport;

            if (cipher == null)
            {
                cipher = new AESCipher();
            }

            this.Cipher = cipher;

            GenerateKey();
        }
コード例 #13
0
ファイル: Startup.cs プロジェクト: mikkeldamm/reservation
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            // Setup factory, delegator (bus) and store
            var aggregateFactory = new AggregateFactory();
            var eventDelegator = new EventDelegator();
            var eventStore = new EventStore(eventDelegator);

            // Create new commandprocessor and add it to IoC
            SetupCommandProcessor(services, eventStore, aggregateFactory);

            // Create new view for getAllReservations and add it to IoC
            SetupViews(services, eventDelegator);
        }
コード例 #14
0
ファイル: Zre.cs プロジェクト: torshy/DotNetZyre
        private Zre(NetMQContext context, string name)
        {
            _name = name;
            _actor = NetMQActor.Create(context, new ZreNode(context));
            if (!string.IsNullOrEmpty(name))
            {
                Name = name;
            }

            EventHandler<NetMQActorEventArgs> onReceive = (sender, e) =>
                                              _receiveEvent.Fire(this, new ZreEventArgs(this));

            _receiveEvent = new EventDelegator<ZreEventArgs>(
                () => _actor.ReceiveReady += onReceive,
                () => _actor.ReceiveReady -= onReceive);
        }
コード例 #15
0
        public void Basics()
        {
            EventHandler <Args <int> > sourceHandler = null;

            var delegator = new EventDelegator <Args <double> >(
                () => Source += sourceHandler,
                () => Source -= sourceHandler);

            sourceHandler = (sender, args) => delegator.Fire(this, new Args <double>(args.Value / 2.0));

            Assert.IsNull(Source);

            var value     = 0.0;
            var callCount = 0;

            EventHandler <Args <double> > delegatorHandler
                = (sender, args) =>
                {
                value = args.Value;
                callCount++;
                };

            delegator.Event += delegatorHandler;

            Assert.IsNotNull(Source);

            Assert.AreEqual(0, callCount);

            Source(this, new Args <int>(5));
            Assert.AreEqual(2.5, value);
            Assert.AreEqual(1, callCount);

            Source(this, new Args <int>(12));
            Assert.AreEqual(6.0, value);
            Assert.AreEqual(2, callCount);

            delegator.Event -= delegatorHandler;

            Assert.IsNull(Source);
        }
コード例 #16
0
 public CheckBalanceCommandHandler(IBankingService bankingService, EventDelegator eventDelegator)
 {
     this.bankingService = bankingService;
     this.eventDelegator = eventDelegator;
 }
コード例 #17
0
 public ListTransactionCommandHandler(IBankingService bankingService, EventDelegator eventDelegator)
 {
     this.bankingService = bankingService;
     this.eventDelegator = eventDelegator;
 }
コード例 #18
0
 public PublishingProductRepository(IProductRepository inner, EventDelegator eventDelegator)
 {
     _inner          = inner ?? throw new System.ArgumentNullException(nameof(inner));
     _eventDelegator = eventDelegator ?? throw new System.ArgumentNullException(nameof(eventDelegator));
 }
コード例 #19
0
ファイル: Actor.cs プロジェクト: skyformat99/NetMQ3-x
        /// <summary>
        /// Create a new Actor within the given shim-handler and state-information.
        /// </summary>
        /// <param name="context">the context for this actor to live within</param>
        /// <param name="shimHandler">this <see cref="IShimHandler"/> is will handle the actions we send to the shim</param>
        /// <param name="state">this generic type represents the state-information that the action will use</param>
        public Actor([NotNull] NetMQContext context, [NotNull] IShimHandler <T> shimHandler, T state)
        {
            m_self = context.CreatePairSocket();
            m_shim = new Shim <T>(shimHandler, context.CreatePairSocket());
            m_self.Options.SendHighWatermark = 1000;
            m_self.Options.SendHighWatermark = 1000;

            EventHandler <NetMQSocketEventArgs> onReceive = (sender, e) =>
                                                            m_receiveEvent.Fire(this, new NetMQActorEventArgs <T>(this));

            EventHandler <NetMQSocketEventArgs> onSend = (sender, e) =>
                                                         m_sendEvent.Fire(this, new NetMQActorEventArgs <T>(this));

            m_receiveEvent = new EventDelegator <NetMQActorEventArgs <T> >(
                () => m_self.ReceiveReady += onReceive,
                () => m_self.ReceiveReady -= onReceive);

            m_sendEvent = new EventDelegator <NetMQActorEventArgs <T> >(
                () => m_self.SendReady += onSend,
                () => m_self.SendReady -= onSend);

            //now binding and connect pipe ends
            string endPoint = string.Empty;

            while (true)
            {
                Action bindAction = () =>
                {
                    endPoint = GetEndPointName();
                    m_self.Bind(endPoint);
                };

                try
                {
                    bindAction();
                    break;
                }
                catch (NetMQException nex)
                {
                    if (nex.ErrorCode == ErrorCode.EFAULT)
                    {
                        bindAction();
                    }
                }
            }

            m_shim.Pipe.Connect(endPoint);

            try
            {
                //Initialise the shim handler
                m_shim.Handler.Initialise(state);
            }
            catch (Exception)
            {
                m_self.Dispose();
                m_shim.Pipe.Dispose();

                throw;
            }

            //Create Shim thread handler
            CreateShimThread();

            // Mandatory handshake for new actor so that constructor returns only
            // when actor has also initialized. This eliminates timing issues at
            // application start up.
            m_self.WaitForSignal();
        }
コード例 #20
0
        public WalletConnect(ClientMeta clientMeta, ITransport transport = null,
                             ICipher cipher   = null,
                             int?chainId      = 1,
                             string bridgeUrl = "https://bridge.walletconnect.org",
                             EventDelegator eventDelegator = null
                             )
        {
            if (clientMeta == null)
            {
                throw new ArgumentException("clientMeta cannot be null!");
            }

            if (string.IsNullOrWhiteSpace(clientMeta.Description))
            {
                throw new ArgumentException("clientMeta must include a valid Description");
            }

            if (string.IsNullOrWhiteSpace(clientMeta.Name))
            {
                throw new ArgumentException("clientMeta must include a valid Name");
            }

            if (string.IsNullOrWhiteSpace(clientMeta.URL))
            {
                throw new ArgumentException("clientMeta must include a valid URL");
            }

            if (clientMeta.Icons == null || clientMeta.Icons.Length == 0)
            {
                throw new ArgumentException("clientMeta must include an array of Icons the Wallet app can use. These Icons must be URLs to images. You must include at least one image URL to use");
            }

            if (eventDelegator == null)
            {
                eventDelegator = new EventDelegator();
            }

            this.Events = eventDelegator;

            this.ClientMetadata = clientMeta;
            this.ChainId        = chainId;

            if (bridgeUrl.StartsWith("https"))
            {
                bridgeUrl = bridgeUrl.Replace("https", "wss");
            }
            else if (bridgeUrl.StartsWith("http"))
            {
                bridgeUrl = bridgeUrl.Replace("http", "ws");
            }

            var topicGuid = Guid.NewGuid();

            _handshakeTopic = topicGuid.ToString();

            clientId = Guid.NewGuid().ToString();

            if (transport == null)
            {
                transport = new WebsocketTransport(eventDelegator);
            }

            this._bridgeUrl = bridgeUrl;
            this.Transport  = transport;

            if (cipher == null)
            {
                cipher = new AESCipher();
            }

            this.Cipher = cipher;

            GenerateKey();
        }
コード例 #21
0
 public WebsocketTransport(EventDelegator eventDelegator)
 {
     this._eventDelegator = eventDelegator;
 }
コード例 #22
0
ファイル: SpaEventProcessor.cs プロジェクト: Ostblock/Ostzone
 public SpaEventProcessor(EventDelegator delegator)
 {
     _delegator = delegator;
 }
コード例 #23
0
 public RecordWithdrawCommandHandler(IBankingService bankingService, EventDelegator eventDelegator)
 {
     this.bankingService = bankingService;
     this.eventDelegator = eventDelegator;
 }
コード例 #24
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="eventDelegator">Event delegator.</param>
 public DomainEventPublisher(EventDelegator eventDelegator)
 {
     _eventDelegator = eventDelegator;
 }