示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositeCommandBase"/> class. This will set
        /// the <see cref="CompositeCommandIdentifier"/> to a identifier value generated by the
        /// <paramref name="idGenerator"/>.
        /// </summary>
        /// <param name="idGenerator">The id generator. This cannot be <c>null</c>.</param>
        protected CompositeCommandBase(IUniqueIdentifierGenerator idGenerator)
        {
            Contract.Requires <ArgumentNullException>(idGenerator != null);

            CompositeCommandIdentifier = idGenerator.GenerateNewId();
            _commands = new List <ICommand>();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandBase"/> class. This will set
        /// the <see cref="CommandIdentifier"/> to a identifier value generated by the
        /// <paramref name="idGenerator"/>.
        /// </summary>
        /// <param name="idGenerator">The id generator. This cannot be <c>null</c>.</param>
        protected CommandBase(IUniqueIdentifierGenerator idGenerator)
        {
            Contract.Requires <ArgumentNullException>(idGenerator != null);

            CommandIdentifier          = idGenerator.GenerateNewId();
            CompositeCommandIdentifier = Guid.Empty;
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandBase"/> class. This will set
        /// the <see cref="CommandIdentifier"/> to a identifier value generated by the 
        /// <paramref name="idGenerator"/>.
        /// </summary>
        /// <param name="idGenerator">The id generator. This cannot be <c>null</c>.</param>
        protected CommandBase(IUniqueIdentifierGenerator idGenerator)
        {
            Contract.Requires<ArgumentNullException>(idGenerator != null);

            CommandIdentifier = idGenerator.GenerateNewId();
            CompositeCommandIdentifier = Guid.Empty;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositeCommandBase"/> class. This will set
        /// the <see cref="CompositeCommandIdentifier"/> to a identifier value generated by the 
        /// <paramref name="idGenerator"/>.
        /// </summary>
        /// <param name="idGenerator">The id generator. This cannot be <c>null</c>.</param>
        protected CompositeCommandBase(IUniqueIdentifierGenerator idGenerator)
        {
            Contract.Requires<ArgumentNullException>(idGenerator != null);

            CompositeCommandIdentifier = idGenerator.GenerateNewId();
            _commands = new List<ICommand>();
        }
示例#5
0
 public FooCommand(IUniqueIdentifierGenerator idGenerator)
     : base(idGenerator)
 {
 }
示例#6
0
        public IdentifiableWebSocket(IUniqueIdentifierGenerator idGenerator, WebSocket socket)
        {
            _socket = socket;

            Id = idGenerator.Next();
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSource"/> class.
 /// </summary>
 protected EventSource()
 {
     _idGenerator  = NcqrsEnvironment.Get <IUniqueIdentifierGenerator>();
     EventSourceId = _idGenerator.GenerateNewId();
 }
示例#8
0
 public FooCommand(IUniqueIdentifierGenerator idGenerator)
     : base(idGenerator)
 {
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventSource"/> class.
 /// </summary>
 protected EventSource()
 {
     _idGenerator = NcqrsEnvironment.Get<IUniqueIdentifierGenerator>();
     EventSourceId = _idGenerator.GenerateNewId();
 }
示例#10
0
        /// <summary>
        /// Invoke in asp.net core pipeline
        /// </summary>
        /// <param name="context">Http context</param>
        /// <param name="webSocketHandler">Websocket handler</param>
        /// <param name="idGenerator">Unique Id generator</param>
        public async Task Invoke(HttpContext context, IWebSocketHandler webSocketHandler, IUniqueIdentifierGenerator idGenerator)
        {
            if (!context.WebSockets.IsWebSocketRequest)
            {
                return;
            }

            var socket = new IdentifiableWebSocket(idGenerator, await context.WebSockets.AcceptWebSocketAsync());

            await webSocketHandler.HandleAsync(socket, _cancellationToken);
        }