Esempio n. 1
0
 public CyberPlatGate(ICyberPlatHttpClient client, CyberPlatGateConfiguration configuration)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     if (configuration == null)
     {
         throw new ArgumentNullException(nameof(configuration));
     }
     m_Client        = client;
     m_Configuration = configuration;
 }
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility <LoggingFacility>(f => f.LogUsing <NLogFactory>().WithConfig("NLog.config"));

            container.Register(
                Component.For <HttpMessageHandler>().ImplementedBy <LoggingHttpHandler>()
                );

            container.Register(
                Component.For <ICyberPlatGate>().ImplementedBy <CyberPlatGate.CyberPlatGate>(),
                Component.For <ICyberPlatHttpClient>().ImplementedBy <CyberPlatHttpClient>(),
                Component.For <ICyberPlatSignatureManager>().ImplementedBy <CyberPlatSignatureManager>()
                );

            // Configurations
            var gateConf = new CyberPlatGateConfiguration()
            {
                AP       = AppSettings.AP,
                SD       = AppSettings.SD,
                OP       = AppSettings.OP,
                PAY_TOOL = AppSettings.PAY_TOOL,
                TERM_ID  = AppSettings.TERM_ID,
                NO_ROUTE = AppSettings.NO_ROUTE,
            };
            var clientConf = new CyberPlatHttpClientConfiguration()
            {
                CheckUrl   = AppSettings.CheckUrl,
                PayUrl     = AppSettings.PayUrl,
                StatusUrl  = AppSettings.StatusUrl,
                TimeoutSec = AppSettings.TimeoutSec,
            };
            var managerConf = new CyberPlatSignatureManagerConfiguration()
            {
                PublicKeyPath     = AppSettings.PublicKeyPath,
                SecretKeyPath     = AppSettings.SecretKeyPath,
                PublicKeySerial   = AppSettings.PublicKeySerial,
                SecretKeyPassword = AppSettings.SecretKeyPassword,
            };

            container.Register(
                Component.For <CyberPlatGateConfiguration>().Instance(gateConf),
                Component.For <CyberPlatHttpClientConfiguration>().Instance(clientConf),
                Component.For <CyberPlatSignatureManagerConfiguration>().Instance(managerConf)
                );
        }