示例#1
0
        private void BindRetryManager(IKernel kernel)
        {
            string retryStrategyName = "ExponentialBackoff";
            var    retryStrategy     = kernel.Get <RetryStrategy>(retryStrategyName);
            var    retryStrategies   = new List <RetryStrategy>()
            {
                kernel.Get <ExponentialBackoff>()
            };

            kernel.Bind <IEnumerable <RetryStrategy> >().ToConstant <List <RetryStrategy> >(retryStrategies).Named("RetryManagerStrategies");

            var retryManager = new CustomRetryManager(retryStrategies, retryStrategyName, null);

            kernel.Bind <CustomRetryManager>().ToConstant(retryManager);
            RetryManager.SetDefault(retryManager);
        }
示例#2
0
        private static void BindRetryManager(MoqMockingKernel kernel)
        {
            string retryStrategyName = "ExponentialBackoff";
            var    retryStrategy     = kernel.Get <RetryStrategy>(retryStrategyName);

            var retryStrategies = new List <RetryStrategy>()
            {
                kernel.Get <ExponentialBackoff>()
            };

            kernel.Bind <IEnumerable <RetryStrategy> >().ToConstant <List <RetryStrategy> >(retryStrategies).Named("RetryManagerStrategies");
            var retryStrategyNameMap = new Dictionary <string, string>();

            retryStrategyNameMap.Add(retryStrategyName, retryStrategyName);

            var retryManager = new CustomRetryManager(retryStrategies, retryStrategyName, retryStrategyNameMap);

            kernel.Bind <CustomRetryManager>().ToConstant(retryManager);
            RetryManager.SetDefault(retryManager);
        }