Exemplo n.º 1
0
 public PlaybackHandler(
     IPlaybackContext playbackContext,
     IPlaybackStorageService playbackStorageService,
     string handlerName,
     IHttpClientPlaybackErrorSimulationService configService)
     : this(new HttpClientHandler(), playbackContext, playbackStorageService, handlerName, configService)
 {
 }
Exemplo n.º 2
0
 public MyPlaybackProxy(IPlaybackContext playbackContext, IPlaybackStorageService playbackStorageService, IHttpClientPlaybackErrorSimulationService configService) :
     base(new System.Net.Http.HttpClient())
 {
     _playbackContext        = playbackContext;
     _playbackStorageService = playbackStorageService;
     _configService          = configService;
     base.HttpClient         = HttpClientFactory.WithPlaybackContext(playbackContext, playbackStorageService, PROXY_NAME, configService);
 }
Exemplo n.º 3
0
        public static HttpClient WithPlaybackContext(
            IPlaybackContext playbackContext,
            IPlaybackStorageService playbackStorageService,
            string prefix,
            IHttpClientPlaybackErrorSimulationService configService)
        {
            var handler    = new PlaybackHandler(playbackContext, playbackStorageService, prefix, configService);
            var httpClient = new HttpClient(handler);

            return(httpClient);
        }
Exemplo n.º 4
0
 public PlaybackHandler(HttpMessageHandler innerHandler,
                        IPlaybackContext playbackContext,
                        IPlaybackStorageService playbackStorageService,
                        string handlerName,
                        IHttpClientPlaybackErrorSimulationService configService)
     : base(innerHandler)
 {
     _playbackStorageService = playbackStorageService;
     _playbackContext        = playbackContext;
     _handlerName            = handlerName;
     _config = configService.GetNamedConfig(handlerName).Result;
 }
Exemplo n.º 5
0
        public PlaybackContext(IHttpContextAccessor accessor, IPlaybackStorageService playbackStorageService)
        {
            if (accessor == null)
            {
                throw new Exception("null Http Context accessor when creating Playback Context");
            }

            if (accessor.HttpContext != null)
            {
                ReadHttpContext(accessor.HttpContext);
            }

            _playbackStorageService = playbackStorageService;
        }
Exemplo n.º 6
0
 public static void AddPlayback(this IServiceCollection services, IConfiguration configuration,
                                IPlaybackStorageService playbackStorageService = null)
 {
     services.AddScoped <IHttpContextAccessor, HttpContextAccessor>();
     services.AddScoped <IPlaybackContext, PlaybackContext>();
     if (playbackStorageService == null)
     {
         if (configuration.GetSection("PlaybackStorage")?.GetValue <string>("ConnectionString")?.ToLower() == "local")
         {
             string name = configuration.GetSection("PlaybackStorage").GetValue <string>("ContainerName");
             playbackStorageService = new PlaybackFileStorageService($"{AssemblyLoadDirectory}\\{name}\\");
         }
         else
         {
             playbackStorageService = new PlaybackBlobStorageService(configuration);
         }
     }
     services.AddScoped <IPlaybackStorageService>(provider => playbackStorageService);
 }
Exemplo n.º 7
0
 public PlaybackMiddleware(RequestDelegate next, IPlaybackStorageService messageStorageService, IPlaybackContext playbackContext)
 {
     _messageStorageService = messageStorageService;
     _next            = next;
     _playbackContext = playbackContext as PlaybackContext;
 }