Exemplo n.º 1
0
        public override string ProcessCommandInternal(IRequestParser command)
        {
            var username = command.Parameters[0];
            var password = command.Parameters[1];

            return(this.ProcessLogin(username, password));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="HomeController" /> class.
        /// </summary>
        /// <param name="homeHandler">The home handler.</param>
        /// <param name="parser">The context builder.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="homeHandler" /> is null.</exception>
        /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="parser" /> is null.</exception>
        public HomeController(IHomeHandler homeHandler, IRequestParser parser)
        {
            Ensure.Argument.IsNotNull(homeHandler, "homeHandler");
            Ensure.Argument.IsNotNull(parser, "parser");

            _homeHandler = homeHandler;
            _parser      = parser;
        }
 public HomeAutomationCommunication(IRequestParser requestParser, IResponseBuilder responseBuilder, IConnectionHandler connectionHandler, IServiceLocator serviceLocator)
 {
     _requestParser       = requestParser;
     _responseBuilder     = responseBuilder;
     _requestHandlerTypes = GetRequestHandlerTypes();
     _connectionHandler   = connectionHandler;
     _serviceLocator      = serviceLocator;
 }
Exemplo n.º 4
0
        public override string ProcessCommandInternal(IRequestParser command)
        {
            var vehicleIndex = int.Parse(command.Parameters[0]) - 1;
            var commentIndex = int.Parse(command.Parameters[1]) - 1;
            var username     = command.Parameters[2];

            return(this.ProcessRemoveComment(vehicleIndex, commentIndex, username));
        }
Exemplo n.º 5
0
        public Dispatcher(IRequestParser parser, IConHostFactory conHostFactory, ILogger <Dispatcher> logger)
        {
            _conHostFactory = Guard.NotNull(conHostFactory, nameof(conHostFactory));
            _parser         = Guard.NotNull(parser, nameof(parser));
            _logger         = Guard.NotNull(logger, nameof(logger));

            _timer = new Timer(OnTimerTick, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));
        }
Exemplo n.º 6
0
        public override string ProcessCommandInternal(IRequestParser command)
        {
            var content      = command.Parameters[0];
            var author       = command.Parameters[1];
            var vehicleIndex = int.Parse(command.Parameters[2]) - 1;

            return(this.ProcessAddComment(content, vehicleIndex, author));
        }
 public ExecutingCommandEndpoint(
     IRequestParser <TDto> requestParser,
     ICommandFactory <TDto, TResponse> todoCommandFactory,
     IResponseInProgressFactory <TResponse> responseInProgressFactory)
 {
     _requestParser             = requestParser;
     _todoCommandFactory        = todoCommandFactory;
     _responseInProgressFactory = responseInProgressFactory;
 }
Exemplo n.º 8
0
        public void RequestParser()
        {
            IRequestParser instance = Factory.RequestParser;

            Assert.That(instance, Is.TypeOf <RequestParser>());

            RequestParser requestParser = (RequestParser)instance;

            Assert.That(requestParser.EntityRepository, Is.Not.Null);
        }
Exemplo n.º 9
0
        public override string ProcessCommandInternal(IRequestParser command)
        {
            var type            = command.Parameters[0];
            var make            = command.Parameters[1];
            var model           = command.Parameters[2];
            var price           = decimal.Parse(command.Parameters[3]);
            var additionalParam = command.Parameters[4];

            var typeEnum = (VehicleType)Enum.Parse(typeof(VehicleType), type, true);

            return(this.ProcessAddVehicle(typeEnum, make, model, price, additionalParam));
        }
Exemplo n.º 10
0
 public HttpPostMiddleware(
     HttpRequestDelegate next,
     IRequestExecutorResolver executorResolver,
     IHttpResultSerializer resultSerializer,
     IRequestParser requestParser,
     NameString schemaName)
 {
     _next             = next;
     _executorResolver = executorResolver;
     _resultSerializer = resultSerializer;
     _requestParser    = requestParser;
     _schemaName       = schemaName;
     executorResolver.RequestExecutorEvicted += EvictRequestExecutor;
 }
Exemplo n.º 11
0
        public string ProcessCommand(IRequestParser command)
        {
            if (this.CanHandle(command))
            {
                return(this.ProcessCommandInternal(command));
            }

            if (this.successor != null)
            {
                return(this.successor.ProcessCommand(command));
            }

            return(string.Format(InvalidCommand, command.Name));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageSharpMiddleware"/> class.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="options">The middleware configuration options.</param>
        /// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param>
        /// <param name="requestParser">An <see cref="IRequestParser"/> instance used to parse image requests for commands.</param>
        /// <param name="resolvers">A collection of <see cref="IImageProvider"/> instances used to resolve images.</param>
        /// <param name="processors">A collection of <see cref="IImageWebProcessor"/> instances used to process images.</param>
        /// <param name="cache">An <see cref="IImageCache"/> instance used for caching images.</param>
        /// <param name="cacheHash">An <see cref="ICacheHash"/>instance used for calculating cached file names.</param>
        /// <param name="commandParser">The command parser</param>
        /// <param name="formatUtilities">Contains various format helper methods based on the current configuration.</param>
        public ImageSharpMiddleware(
            RequestDelegate next,
            IOptions <ImageSharpMiddlewareOptions> options,
            ILoggerFactory loggerFactory,
            IRequestParser requestParser,
            IEnumerable <IImageProvider> resolvers,
            IEnumerable <IImageWebProcessor> processors,
            IImageCache cache,
            ICacheHash cacheHash,
            CommandParser commandParser,
            FormatUtilities formatUtilities)
        {
            Guard.NotNull(next, nameof(next));
            Guard.NotNull(options, nameof(options));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(requestParser, nameof(requestParser));
            Guard.NotNull(resolvers, nameof(resolvers));
            Guard.NotNull(processors, nameof(processors));
            Guard.NotNull(cache, nameof(cache));
            Guard.NotNull(cacheHash, nameof(cacheHash));
            Guard.NotNull(commandParser, nameof(commandParser));
            Guard.NotNull(formatUtilities, nameof(formatUtilities));

            this.next          = next;
            this.options       = options.Value;
            this.requestParser = requestParser;
            this.providers     = resolvers as IImageProvider[] ?? resolvers.ToArray();
            this.processors    = processors as IImageWebProcessor[] ?? processors.ToArray();
            this.cache         = cache;
            this.cacheHash     = cacheHash;
            this.commandParser = commandParser;
            this.parserCulture = this.options.UseInvariantParsingCulture
                ? CultureInfo.InvariantCulture
                : CultureInfo.CurrentCulture;

            var commands = new HashSet <string>();

            foreach (IImageWebProcessor processor in this.processors)
            {
                foreach (string command in processor.Commands)
                {
                    commands.Add(command);
                }
            }

            this.knownCommands = commands;

            this.logger          = loggerFactory.CreateLogger <ImageSharpMiddleware>();
            this.formatUtilities = formatUtilities;
        }
Exemplo n.º 13
0
        private IList <IRequestParser> ReadCommands()
        {
            var commands = new List <IRequestParser>();

            var currentLine = inputOutputProvider.Read();

            while (!string.IsNullOrEmpty(currentLine))
            {
                IRequestParser currentCommand = this.dealershipFactory.CreateRequestParser(currentLine);
                commands.Add(currentCommand);
                currentLine = inputOutputProvider.Read();
            }

            return(commands);
        }
Exemplo n.º 14
0
        public override string ProcessCommandInternal(IRequestParser command)
        {
            var username  = command.Parameters[0];
            var firstName = command.Parameters[1];
            var lastName  = command.Parameters[2];
            var password  = command.Parameters[3];

            var role = Role.Normal;

            if (command.Parameters.Count > 4)
            {
                role = (Role)Enum.Parse(typeof(Role), command.Parameters[4]);
            }

            return(this.ProcessRegisterUser(username, firstName, lastName, password, role));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageSharpMiddleware"/> class.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="options">The middleware configuration options.</param>
        /// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param>
        /// <param name="memoryAllocator">An <see cref="MemoryAllocator"/> instance used to allocate arrays transporting encoded image data.</param>
        /// <param name="requestParser">An <see cref="IRequestParser"/> instance used to parse image requests for commands.</param>
        /// <param name="resolvers">A collection of <see cref="IImageProvider"/> instances used to resolve images.</param>
        /// <param name="processors">A collection of <see cref="IImageWebProcessor"/> instances used to process images.</param>
        /// <param name="cache">An <see cref="IImageCache"/> instance used for caching images.</param>
        /// <param name="cacheHash">An <see cref="ICacheHash"/>instance used for calculating cached file names.</param>
        /// <param name="formatUtilities">Contains various format helper methods based on the current configuration.</param>
        public ImageSharpMiddleware(
            RequestDelegate next,
            IOptions <ImageSharpMiddlewareOptions> options,
            ILoggerFactory loggerFactory,
            MemoryAllocator memoryAllocator,
            IRequestParser requestParser,
            IEnumerable <IImageProvider> resolvers,
            IEnumerable <IImageWebProcessor> processors,
            IImageCache cache,
            ICacheHash cacheHash,
            FormatUtilities formatUtilities)
        {
            Guard.NotNull(next, nameof(next));
            Guard.NotNull(options, nameof(options));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(memoryAllocator, nameof(memoryAllocator));
            Guard.NotNull(requestParser, nameof(requestParser));
            Guard.NotNull(resolvers, nameof(resolvers));
            Guard.NotNull(processors, nameof(processors));
            Guard.NotNull(cache, nameof(cache));
            Guard.NotNull(cacheHash, nameof(cacheHash));
            Guard.NotNull(AsyncLock, nameof(AsyncLock));

            this.next            = next;
            this.options         = options.Value;
            this.memoryAllocator = memoryAllocator;
            this.requestParser   = requestParser;
            this.providers       = resolvers as IImageProvider[] ?? resolvers.ToArray();
            this.processors      = processors as IImageWebProcessor[] ?? processors.ToArray();
            this.cache           = cache;
            this.cacheHash       = cacheHash;

            var commands = new HashSet <string>();

            foreach (IImageWebProcessor processor in this.processors)
            {
                foreach (string command in processor.Commands)
                {
                    commands.Add(command);
                }
            }

            this.knownCommands = commands;

            this.logger          = loggerFactory.CreateLogger <ImageSharpMiddleware>();
            this.formatUtilities = formatUtilities;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageSharpMiddleware"/> class.
        /// </summary>
        /// <param name="next">The next middleware in the pipeline.</param>
        /// <param name="options">The middleware configuration options.</param>
        /// <param name="loggerFactory">An <see cref="ILoggerFactory"/> instance used to create loggers.</param>
        /// <param name="memoryAllocator">An <see cref="MemoryAllocator"/> instance used to allocate arrays transporting encoded image data.</param>
        /// <param name="requestParser">An <see cref="IRequestParser"/> instance used to parse image requests for commands.</param>
        /// <param name="resolvers">A collection of <see cref="IImageProvider"/> instances used to resolve images.</param>
        /// <param name="processors">A collection of <see cref="IImageWebProcessor"/> instances used to process images.</param>
        /// <param name="cache">An <see cref="IImageCache"/> instance used for caching images.</param>
        /// <param name="cacheHash">An <see cref="ICacheHash"/>instance used for calculating cached file names.</param>
        /// <param name="asyncKeyLock">An <see cref="IAsyncKeyLock"/> instance used for providing locking during processing.</param>
        public ImageSharpMiddleware(
            RequestDelegate next,
            IOptions <ImageSharpMiddlewareOptions> options,
            ILoggerFactory loggerFactory,
            MemoryAllocator memoryAllocator,
            IRequestParser requestParser,
            IEnumerable <IImageProvider> resolvers,
            IEnumerable <IImageWebProcessor> processors,
            IImageCache cache,
            ICacheHash cacheHash,
            IAsyncKeyLock asyncKeyLock)
        {
            Guard.NotNull(next, nameof(next));
            Guard.NotNull(options, nameof(options));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(memoryAllocator, nameof(memoryAllocator));
            Guard.NotNull(requestParser, nameof(requestParser));
            Guard.NotNull(resolvers, nameof(resolvers));
            Guard.NotNull(processors, nameof(processors));
            Guard.NotNull(cache, nameof(cache));
            Guard.NotNull(cache, nameof(cacheHash));
            Guard.NotNull(asyncKeyLock, nameof(asyncKeyLock));

            this.next            = next;
            this.options         = options.Value;
            this.memoryAllocator = memoryAllocator;
            this.requestParser   = requestParser;
            this.resolvers       = resolvers;
            this.processors      = processors;
            this.cache           = cache;
            this.cacheHash       = cacheHash;
            this.asyncKeyLock    = asyncKeyLock;

            var commands = new List <string>();

            foreach (IImageWebProcessor processor in this.processors)
            {
                commands.AddRange(processor.Commands);
            }

            this.knownCommands = commands;

            this.logger = loggerFactory.CreateLogger <ImageSharpMiddleware>();
        }
Exemplo n.º 17
0
        public ResponseProvider(IRequestParser requestParser,
                                IHttpResponseFactory responseFactory,
                                IHandler headHandler)
        {
            if (requestParser == null)
            {
                throw new ArgumentNullException(nameof(requestParser));
            }

            if (responseFactory == null)
            {
                throw new ArgumentNullException(nameof(responseFactory));
            }

            if (headHandler == null)
            {
                throw new ArgumentNullException(nameof(headHandler));
            }

            this._requestParser   = requestParser;
            this._responseFactory = responseFactory;
            this._headHandler     = headHandler;
        }
 /// <summary>Constructor</summary>
 /// <param name="secretStore">Vault Secret Store</param>
 /// <param name="contextParser">Owin Context Parser</param>
 public VaultBasicAuthenticationSecretParser(IVaultSecretStore secretStore, IRequestParser contextParser)
 {
     this.secretStore   = secretStore.ThrowIfNull(nameof(secretStore));
     this.contextParser = contextParser.ThrowIfNull(nameof(contextParser));
 }
Exemplo n.º 19
0
 public override string ProcessCommandInternal(IRequestParser command)
 {
     this.userProvider.LoggedUser = null;
     this.userProvider.Users      = new List <IUser>();
     return("Reset compleate.");
 }
Exemplo n.º 20
0
 public override bool CanHandle(IRequestParser command)
 {
     return(command.Name.Equals("Reset"));
 }
Exemplo n.º 21
0
 public override string ProcessCommandInternal(IRequestParser command)
 {
     return(this.ProcessLogout());
 }
 // Dependency Inversion and Liskov Substitution Principles
 public ResponseProvider(
     IRequestParser requestParser, IRequestProccessor requestProccessor)
 {
     this.requestParser = requestParser;
     this.requestProccessor = requestProccessor;
 }
Exemplo n.º 23
0
 public override string ProcessCommandInternal(IRequestParser command)
 {
     return(this.ProcessShowAllUsers());
 }
Exemplo n.º 24
0
 public override bool CanHandle(IRequestParser command)
 {
     return(command.Name.Equals("AddVehicle"));
 }
Exemplo n.º 25
0
        public override string ProcessCommandInternal(IRequestParser command)
        {
            var username = command.Parameters[0];

            return(this.ShowUserVehicles(username));
        }
Exemplo n.º 26
0
 public ResponseProvider(IHandler handler, IHttpResponseFactory responseFactory, IRequestParser requestParser)
 {
     this.httpResponseFactory = responseFactory;
     this.handler             = handler;
     this.requestParser       = requestParser;
 }
Exemplo n.º 27
0
 public DefaultStyxEngine(IHandshakeNegotiator handshakeNegotiator, ILogger logger, IRequestParser requestParser)
 {
     _handshakeNegotiator = handshakeNegotiator;
     _logger = logger;
     _requestParser = requestParser;
 }
 public ClientRequestProcessor(ICommandLocator commandLocator, IRequestParser requestParser)
 {
     _commandLocator = commandLocator;
     _requestParser = requestParser;
 }
Exemplo n.º 29
0
 public MailGunWebhooksController(IRequestParser requestParser)
 {
     _requestParser = requestParser;
 }
Exemplo n.º 30
0
 public abstract string ProcessCommandInternal(IRequestParser command);
Exemplo n.º 31
0
 public abstract bool CanHandle(IRequestParser command);
 // Dependency Inversion and Liskov Substitution Principles
 public ResponseProvider(
     IRequestParser requestParser, IRequestProccessor requestProccessor)
 {
     this.requestParser     = requestParser;
     this.requestProccessor = requestProccessor;
 }
Exemplo n.º 33
0
 public ClientRequestProcessor(ICommandLocator commandLocator, IRequestParser requestParser)
 {
     _commandLocator = commandLocator;
     _requestParser  = requestParser;
 }