Example #1
0
        private Task Handle(AssetCreatedEvent evt)
        {
            _assetsCache.Set(evt.Id, new Asset
            {
                Id                   = evt.Id,
                Accuracy             = evt.Accuracy,
                LowVolumeAmount      = evt.LowVolumeAmount,
                CashoutMinimalAmount = evt.CashoutMinimalAmount
            });

            return(Task.CompletedTask);
        }
        private void RegisterServices(ContainerBuilder builder)
        {
            var settings = _appSettings.CurrentValue.LimitationsSettings;

            builder.RegisterType <StartupManager>()
            .As <IStartupManager>()
            .SingleInstance();

            builder.RegisterType <CurrencyConverter>()
            .As <ICurrencyConverter>()
            .SingleInstance()
            .WithParameter(TypedParameter.From(settings.ConvertibleAssets))
            .WithParameter(TypedParameter.From(settings.BaseAsset));

            builder.RegisterType <AntiFraudCollector>()
            .As <IAntiFraudCollector>()
            .SingleInstance()
            .WithParameter(TypedParameter.From(settings.RedisInstanceName));

            builder.RegisterType <CashOperationsCollector>()
            .As <ICashOperationsCollector>()
            .SingleInstance()
            .WithParameter(TypedParameter.From(settings.RedisInstanceName));

            builder.RegisterType <CashTransfersCollector>()
            .As <ICashTransfersCollector>()
            .SingleInstance()
            .WithParameter(TypedParameter.From(settings.RedisInstanceName));

            builder.RegisterType <LimitationChecker>()
            .As <ILimitationCheck>()
            .SingleInstance()
            .WithParameter(TypedParameter.From(settings.Limits))
            .WithParameter(TypedParameter.From(settings.AttemptRetainInMinutes));

            builder.Register(ctx =>
            {
                var assetService = ctx.Resolve <IAssetsService>();
                var assetsCache  = new OnDemandDataCache <Asset>();
                var assets       = assetService.AssetGetAll();

                foreach (var asset in assets)
                {
                    assetsCache.Set(asset.Id, new Asset
                    {
                        Id = asset.Id,
                        LowVolumeAmount      = asset.LowVolumeAmount,
                        Accuracy             = asset.Accuracy,
                        CashoutMinimalAmount = asset.CashoutMinimalAmount
                    });
                }

                return(assetsCache);
            }).SingleInstance();
        }