Beispiel #1
0
        private void Initialize(IOptions <S3Config> options, INetworkDriver networkDriver, ILoggerFactory loggerFactory)
        {
            Assembly assembly = typeof(S3Config).Assembly;

            SimpleServiceProvider provider = new SimpleServiceProvider(new Tuple <Type, object>(typeof(IOptions <S3Config>), options));

            IEnumerable <IValidator>       validators       = CreateInstances <IValidator>(assembly, provider);
            IEnumerable <IRequestMarshal>  requestMarshals  = CreateInstances <IRequestMarshal>(assembly, provider);
            IEnumerable <IResponseMarshal> responseMarshals = CreateInstances <IResponseMarshal>(assembly, provider);

            ValidatorFactory      validatorFactory     = new ValidatorFactory(validators);
            IMarshalFactory       marshalFactory       = new MarshalFactory(requestMarshals, responseMarshals);
            IScopeBuilder         scopeBuilder         = new ScopeBuilder(options);
            ISigningKeyBuilder    signingKeyBuilder    = new SigningKeyBuilder(options, loggerFactory.CreateLogger <SigningKeyBuilder>());
            ISignatureBuilder     signatureBuilder     = new SignatureBuilder(signingKeyBuilder, scopeBuilder, loggerFactory.CreateLogger <SignatureBuilder>(), options);
            IAuthorizationBuilder authorizationBuilder = new AuthorizationHeaderBuilder(options, scopeBuilder, signatureBuilder, loggerFactory.CreateLogger <AuthorizationHeaderBuilder>());
            DefaultRequestHandler requestHandler       = new DefaultRequestHandler(options, validatorFactory, marshalFactory, networkDriver, authorizationBuilder, Enumerable.Empty <IRequestStreamWrapper>(), loggerFactory.CreateLogger <DefaultRequestHandler>());

            ObjectOperations objectOperations = new ObjectOperations(requestHandler, Enumerable.Empty <IRequestWrapper>(), Enumerable.Empty <IResponseWrapper>());

            _objectClient = new S3ObjectClient(objectOperations);

            BucketOperations bucketOperations = new BucketOperations(requestHandler);

            _bucketClient = new S3BucketClient(bucketOperations);

            MultipartOperations multipartOperations = new MultipartOperations(requestHandler, Enumerable.Empty <IRequestWrapper>(), Enumerable.Empty <IResponseWrapper>());

            _multipartClient = new S3MultipartClient(multipartOperations, objectOperations);

            Transfer = new Transfer(objectOperations, multipartOperations);
        }
Beispiel #2
0
        public IHandlerConfig Do <TInput>(Func <TInput, IResponseFiller> action) where TInput : new()
        {
            var handler = new DefaultRequestHandler(
                _matcher,
                new ArgumentAwareResponseFiller <TInput>(action));

            return(new ConsHandlerConfig(_parent, handler, _context));
        }
Beispiel #3
0
        public void Main(string[] args)
        {

            var requestHandler = new DefaultRequestHandler();
            var listener = new HmRpcServer(requestHandler);

            listener.OnClientConnected += clientInfo =>
            {
                Console.Write("Incoming! (Local={0}, Remote=", clientInfo.LocalEndPoint);
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.Write(clientInfo.RemoteEndPoint);
                Console.ResetColor();
                Console.WriteLine(")");
            };

            listener.OnClientDisconnected += clientInfo =>
            {
                Debug.WriteLine("Client {0} disconnected.", clientInfo.RemoteEndPoint);
            };

            listener.Start();

            try
            {
                Test().Wait();
            }
            catch (AggregateException aggrEx)
            {
                var ex = aggrEx.InnerException;
                Debug.WriteLine("Error: {0}", (object)ex.ToString());
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
            //s.Wait();

            listener.Dispose();
        }
Beispiel #4
0
        public void Main(string[] args)
        {
            var requestHandler = new DefaultRequestHandler();
            var listener       = new HmRpcServer(requestHandler);

            listener.OnClientConnected += clientInfo =>
            {
                Console.Write("Incoming! (Local={0}, Remote=", clientInfo.LocalEndPoint);
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.Write(clientInfo.RemoteEndPoint);
                Console.ResetColor();
                Console.WriteLine(")");
            };

            listener.OnClientDisconnected += clientInfo =>
            {
                Debug.WriteLine("Client {0} disconnected.", clientInfo.RemoteEndPoint);
            };

            listener.Start();

            try
            {
                Test().Wait();
            }
            catch (AggregateException aggrEx)
            {
                var ex = aggrEx.InnerException;
                Debug.WriteLine("Error: {0}", (object)ex.ToString());
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
            //s.Wait();

            listener.Dispose();
        }
Beispiel #5
0
 public void SetUp()
 {
     _subject = new DefaultRequestHandler();
     _channel = MockRepository.GenerateMock <IDuplexChannel>();
 }