Ejemplo n.º 1
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            if (this.commandChannel != null)
            {
                try
                {
                    // ReSharper disable once SuspiciousTypeConversion.Global
                    ((ICommunicationObject)this.commandChannel).Abort();
                }
                catch
                {
                    // swallow!
                }

                this.commandChannel = null;
            }

            if (this.queryChannel != null)
            {
                try
                {
                    // ReSharper disable once SuspiciousTypeConversion.Global
                    ((ICommunicationObject)this.queryChannel).Abort();
                }
                catch
                {
                    // swallow!
                }

                this.queryChannel = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceClient" /> class.
        /// </summary>
        /// <param name="clientChannelProvider">The client channel provider.</param>
        public ServiceClient(IClientChannelProvider clientChannelProvider)
        {
            this.commandChannel = clientChannelProvider.GetCommandChannel(this);
            this.queryChannel   = clientChannelProvider.GetQueryChannel(this);

            this.originationHash = Process.GetCurrentProcess().Id;
        }
Ejemplo n.º 3
0
 public StatQueryHandler(
     IQueryContract queryContract,
     ICommandContract commandContract,
     IQueryHandler nextQueryHandler,
     StatQuery defaultQueryResponse,
     IServerMessageHandlerResolver messageHandlerResolver)
     : base(queryContract, commandContract, nextQueryHandler, defaultQueryResponse, messageHandlerResolver)
 {
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WstServiceClient" /> class.
        /// </summary>
        /// <param name="clientChannelProvider">The client channel provider.</param>
        public WstServiceClient(IClientChannelProvider clientChannelProvider)
        {
            if (clientChannelProvider == null)
            {
                throw new ArgumentNullException(nameof(clientChannelProvider));
            }

            this.commandChannel = clientChannelProvider.GetCommandChannel(this);
            this.queryChannel   = clientChannelProvider.GetQueryChannel(this);

            this.originationHash = Process.GetCurrentProcess().Id;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QueryHandlerBase{TQuery}" /> class.
        /// </summary>
        /// <param name="queryContract">The query contract.</param>
        /// <param name="commandContract">The command contract.</param>
        /// <param name="nextQueryHandler">The next query handler in the chain.</param>
        /// <param name="defaultQueryResponse">The default query response.</param>
        /// <param name="messageHandlerResolver">The message handler resolver.</param>
        protected QueryHandlerBase(
            IQueryContract queryContract,
            ICommandContract commandContract,
            IQueryHandler nextQueryHandler,
            TQuery defaultQueryResponse,
            IServerMessageHandlerResolver messageHandlerResolver)
        {
            this.response = defaultQueryResponse;
            this.messageHandlerResolver = messageHandlerResolver;

            nextQueryHandler.AddHandler(this);

            queryContract.QuerySubmitted += this.OnQuerySubmitted;

            commandContract.MessagePublished  += this.OnMessagePublished;
            commandContract.MessageSubscribed += this.OnMessageSubscribed;
        }
        /// <summary>
        /// Gets the query handlers.
        /// </summary>
        /// <param name="queryContract">The query contract.</param>
        /// <param name="commandContract">The command contract.</param>
        /// <param name="rootHandler">The root handler.</param>
        /// <returns>An array of query handlers.</returns>
        public IQueryHandler[] GetQueryHandlers(
            IQueryContract queryContract,
            ICommandContract commandContract,
            IQueryHandler rootHandler)
        {
            if (this.queryHandlers != null)
            {
                return(this.queryHandlers.ToArray());
            }

            if (this.serverServiceTypeProvider == null)
            {
                this.serverServiceTypeProvider = ServiceTypeProvider.Instance;
            }

            var queryHandlerCollectionFactory = this.serverServiceTypeProvider.QueryHandlerCollectionFactory;

            this.queryHandlers = queryHandlerCollectionFactory.Create(
                queryContract,
                commandContract,
                rootHandler);

            return(this.queryHandlers.ToArray());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a list of query handlers.
        /// </summary>
        /// <param name="queryContract">The query contract.</param>
        /// <param name="commandContract">The command contract.</param>
        /// <param name="rootHandler">The root query handler.</param>
        /// <returns>A list of query handlers.</returns>
        public IList <IQueryHandler> Create(
            IQueryContract queryContract,
            ICommandContract commandContract,
            IQueryHandler rootHandler)
        {
            var result = new List <IQueryHandler>
            {
                new SessionTimeQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <SessionTimeQuery>().Create(),
                    this.messageHandlerResolver),
                new MageKnightQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <MageKnightQuery>().Create(),
                    this.messageHandlerResolver),
                new UserQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <UserQuery>().Create(),
                    this.messageHandlerResolver),
                new DialQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <DialQuery>().Create(),
                    this.messageHandlerResolver),
                new ClickQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <ClickQuery>().Create(),
                    this.messageHandlerResolver),
                new StatQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <StatQuery>().Create(),
                    this.messageHandlerResolver),
                new UserCollectionQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <UserCollectionQuery>().Create(),
                    this.messageHandlerResolver),
                new GameQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <GameQuery>().Create(),
                    this.messageHandlerResolver),
                new GamesQueryHandler(
                    queryContract,
                    commandContract,
                    rootHandler,
                    this.queryFactoryResolver.GetFactory <GamesQuery>().Create(),
                    this.messageHandlerResolver),
            };

            return(result);
        }
 /// <summary>
 /// Gets the command handlers.
 /// </summary>
 /// <param name="commandContract">The command contract.</param>
 /// <returns>An array of objects.</returns>
 public object[] GetCommandHandlers(ICommandContract commandContract)
 {
     return(new object[0]);
 }