示例#1
0
        static Container CreateContainer(IDetailedExceptionLogger detailedLogger)
        {
            Container container = null;

            try {
                container = new Container();

                // ShipHub Configuration
                var config = ShipHubCloudConfiguration.Instance;
                container.RegisterSingleton(config);

                // AutoMapper
                container.RegisterSingleton(() => {
                    var mapperConfig = new MapperConfiguration(cfg => {
                        cfg.AddProfile <GitHubToDataModelProfile>();
                    });
                    return(mapperConfig.CreateMapper());
                });

                // Service Bus
                container.RegisterSingleton <IServiceBusFactory>(() => {
                    // HACK: This is gross
                    var sbf = new ServiceBusFactory();
                    sbf.Initialize().GetAwaiter().GetResult();
                    return(sbf);
                });

                // Orleans
                container.RegisterSingleton <IAsyncGrainFactory>(() => {
                    var factory = new OrleansAzureClient(config.DeploymentId, config.DataConnectionString);
                    factory.Configuration.DefaultTraceLevel = Orleans.Runtime.Severity.Error;
                    return(factory);
                });

                // Queue Client
                container.RegisterSingleton <IShipHubQueueClient, ShipHubQueueClient>();

                // IDetailedExceptionLogger
                container.RegisterSingleton(() => detailedLogger);

                // ChargeBee
                var chargeBeeHostAndApiKey = ShipHubCloudConfiguration.Instance.ChargeBeeHostAndKey;
                if (!chargeBeeHostAndApiKey.IsNullOrWhiteSpace())
                {
                    var parts = chargeBeeHostAndApiKey.Split(':');
                    container.RegisterSingleton(() => new cb.ChargeBeeApi(parts[0], parts[1]));
                }

                container.Verify();
            } catch {
                if (container != null)
                {
                    container.Dispose();
                    throw;
                }
            }

            return(container);
        }
示例#2
0
 public RollTokens(IShipHubConfiguration config, IDetailedExceptionLogger logger)
     : base(logger)
 {
     _config = config;
 }
 protected LoggingHandlerBase(IDetailedExceptionLogger logger)
 {
     _logger = logger;
 }
 public WebhookReaperTimer(IAsyncGrainFactory grainFactory, IDetailedExceptionLogger logger)
     : base(logger)
 {
     _grainFactory = grainFactory;
 }
示例#5
0
 public TestQueueHandler(IDetailedExceptionLogger logger) : base(logger)
 {
 }