Ejemplo n.º 1
0
 public ServiceCommunicator(IRequestGenerator <string, ServiceRequest> requestGenerator,
                            IBackendCommunicator <ServiceRequest, ServiceResponse> backendCommunicator, ILogger logger)
 {
     this.requestGenerator    = requestGenerator;
     this.backendCommunicator = backendCommunicator;
     this.logger = logger;
 }
Ejemplo n.º 2
0
        public Client(IHttpClientFactory clientFactory, IRequestGenerator requestGenerator, Options options)
        {
            _options = options;
            IRequestExecuter requestExecuter = new RequestExecuter(
                clientFactory.CreateHttpClient(new HttpClientOptions
            {
                AddTokenToRequests     = true,
                TokenRetriever         = () => _options.AccessToken,
                ReadRequestsPerSecond  = options.ReadRequestsPerSecond,
                WriteRequestsPerSecond = options.WriteRequestsPerSecond,
            }),
                clientFactory.CreateHttpClient(new HttpClientOptions()));

            if (options.AutoRetry)
            {
                requestExecuter = new AutoRetryRequestExecuter(requestExecuter)
                {
                    NumberOfRetries = options.NumberOfRetries
                };
            }

            RequestGenerator = requestGenerator;

            Core     = new Core(requestExecuter, requestGenerator.Core, options);
            Business = new Business(requestExecuter, requestGenerator);
        }
Ejemplo n.º 3
0
 public Business(RequestExecuter requestExecuter, IRequestGenerator requestGenerator, Options options)
 {
     Info     = new Info(requestExecuter, requestGenerator.Business.TeamInfo, options);
     Members  = new Members(requestExecuter, requestGenerator.Business.TeamMembers, options);
     Reports  = new Reports(requestExecuter, requestGenerator.Business.Reports, options);
     AuditLog = new AuditLog(requestExecuter, requestGenerator.Business.AuditLog, options);
 }
Ejemplo n.º 4
0
 public Business(IRequestExecuter requestExecuter, IRequestGenerator requestGenerator, Options options)
 {
     Info = new Info(requestExecuter, requestGenerator.Business.TeamInfo, options);
     Members = new Members(requestExecuter, requestGenerator.Business.TeamMembers, options);
     Reports = new Reports(requestExecuter, requestGenerator.Business.Reports, options);
     AuditLog = new AuditLog(requestExecuter, requestGenerator.Business.AuditLog, options);
 }
Ejemplo n.º 5
0
        public IRequestGenerator Execute(GeneratorArgs args, string pluginDirectory)
        {
            var loader = new RequestGeneratorPluginLoader(pluginDirectory);
            IRequestGenerator requestGenerator = loader.Load().First(g => g.Name.Equals(args.Name, StringComparison.InvariantCultureIgnoreCase));

            // add options
            if (args.Arguments != null && args.Arguments.Count > 0)
            {
                for (int i = 0; i < args.Arguments.Count; i++)
                {
                    string argument = null;
                    string value    = null;
                    if (args.Arguments[i].StartsWith("#"))
                    {
                        argument = args.Arguments[i].TrimStart('#');
                        value    = args.Arguments[i + 1];
                    }

                    int index = -1;
                    if (!string.IsNullOrWhiteSpace(argument) &&
                        (index = requestGenerator.Options.FindLastIndex(o => o.Description.Key.Equals(argument))) > -1)
                    {
                        requestGenerator.Options[index].Value = value;
                    }
                }
            }

            return(requestGenerator);
        }
Ejemplo n.º 6
0
        public Client(IHttpClientFactory clientFactory, IRequestGenerator requestGenerator, Options options)
        {
            _options = options;
            IRequestExecuter requestExecuter = new RequestExecuter(
                clientFactory.CreateHttpClient(new HttpClientOptions
                    {
                        AddTokenToRequests = true,
                        TokenRetriever = () => _options.AccessToken,
                        ReadRequestsPerSecond = options.ReadRequestsPerSecond,
                        WriteRequestsPerSecond = options.WriteRequestsPerSecond,
                    }),
                clientFactory.CreateHttpClient(new HttpClientOptions()));

            if (options.AutoRetry)
            {
                requestExecuter = new AutoRetryRequestExecuter(requestExecuter)
                    {
                        NumberOfRetries = options.NumberOfRetries
                    };
            }

            RequestGenerator = requestGenerator;

            Core = new Core(requestExecuter, requestGenerator.Core, options);
            Business = new Business(requestExecuter, requestGenerator, options);
        }
Ejemplo n.º 7
0
        private IEnumerable <IRequestGenerator> LoadGeneratorPlugins()
        {
            var generators = new List <IRequestGenerator>();

            if (!Directory.Exists(PluginDirectory))
            {
                Directory.CreateDirectory(PluginDirectory);
            }

            List <string> plugins = new List <string>();

            var pluginDirs = Directory.EnumerateDirectories(PluginDirectory).ToList();

            pluginDirs.Add(PluginDirectory);
            foreach (var dir in pluginDirs)
            {
                var files = Directory.EnumerateFiles(dir);
                plugins.AddRange(files.Where(f =>
                {
                    var file = new FileInfo(f);
                    if (file.Extension.Equals(".dll", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(true);
                    }

                    return(false);
                }));
            }

            //loads a new dll to the current AppDomain.
            List <Assembly> assemblies = new List <Assembly>();

            foreach (var plugin in plugins)
            {
                var a = Assembly.LoadFrom(plugin);
                assemblies.Add(a);
            }

            foreach (Assembly a in assemblies)
            {
                try
                {
                    foreach (Type t in a.GetTypes())
                    {
                        if (t?.GetInterface(typeof(IRequestGenerator).FullName) != null)
                        {
                            IRequestGenerator pluginClass = Activator.CreateInstance(t) as IRequestGenerator;
                            generators.Add(pluginClass);
                        }
                    }
                }
                catch (Exception e)
                {
                    // can I get a logging framework?
                }
            }

            return(generators);
        }
Ejemplo n.º 8
0
 public Business(IRequestExecuter requestExecuter, IRequestGenerator requestGenerator)
 {
     Info     = new Info(requestExecuter, requestGenerator.Business.TeamInfo);
     Members  = new Members(requestExecuter, requestGenerator.Business.TeamMembers);
     Reports  = new Reports(requestExecuter, requestGenerator.Business.Reports);
     AuditLog = new AuditLog(requestExecuter, requestGenerator.Business.AuditLog);
     Groups   = new Groups(requestExecuter, requestGenerator.Business.Groups);
 }
Ejemplo n.º 9
0
 public Business(IRequestExecuter requestExecuter, IRequestGenerator requestGenerator)
 {
     Info = new Info(requestExecuter, requestGenerator.Business.TeamInfo);
     Members = new Members(requestExecuter, requestGenerator.Business.TeamMembers);
     Reports = new Reports(requestExecuter, requestGenerator.Business.Reports);
     AuditLog = new AuditLog(requestExecuter, requestGenerator.Business.AuditLog);
     Groups = new Groups(requestExecuter, requestGenerator.Business.Groups);
 }
 public SwaggerBlueprintDecoratorProvider(
     IRequestGenerator requestGenerator,
     IHttpClientFactory httpClientFactory,
     IYamlSerializers yamlSerializers)
 {
     _requestGenerator  = requestGenerator;
     _httpClientFactory = httpClientFactory;
     _yamlSerializers   = yamlSerializers;
 }
Ejemplo n.º 11
0
        public Client(IHttpClientFactory clientFactory, IRequestGenerator requestGenerator, Options options)
        {
            _options = options;

            _clientOAuth = clientFactory.CreateHttpClient(new HttpClientOptions());
            _clientContent = clientFactory.CreateHttpClient(new HttpClientOptions {AddTokenToRequests = true, TokenRetriever = () => _options.AccessToken});
            _clientContentNoRedirection = clientFactory.CreateHttpClient(new HttpClientOptions {AllowAutoRedirect = false, AddTokenToRequests = true, TokenRetriever = () => _options.AccessToken});


            RequestGenerator = requestGenerator;
        }
Ejemplo n.º 12
0
 public SwaggerBlueprintDecorator(
     IBlueprintPackage package,
     IRequestGenerator requestGenerator,
     IHttpClientFactory httpClientFactory,
     IYamlSerializers yamlSerializers)
     : base(package)
 {
     _requestGenerator  = requestGenerator;
     _httpClientFactory = httpClientFactory;
     _yamlSerializers   = yamlSerializers;
 }
 public MutliRequestProcessCommand(
     ILogger <MutliRequestProcessCommand> logger,
     IMessageService messaging,
     IRequestGenerator requestGenerator,
     IOptions <RequestGenerationOptions> genOptions,
     IHttpClientFactory httpClientFactory)
 {
     _logger            = logger;
     _messaging         = messaging;
     _reqGen            = requestGenerator;
     _reqObjectCount    = genOptions?.Value?.RequestObjectsCount ?? DefaultRequestObjectsCount;
     _httpClientFactory = httpClientFactory;
 }
Ejemplo n.º 14
0
        internal static void DrawGenerator(IRequestGenerator generator)
        {
            Console.WriteLine(GeneratorResultString,
                              generator.Name,
                              generator.Description);

            foreach (var option in generator.Options)
            {
                Console.WriteLine(GeneratorOptionResultString,
                                  option.Description.Key,
                                  option.Description.Description,
                                  option.Description.DefaultValue,
                                  option.Description.IsRequired);
            }
        }
Ejemplo n.º 15
0
        public Client(IHttpClientFactory clientFactory, IRequestGenerator requestGenerator, Options options)
        {
            _options = options;

            _clientOAuth   = clientFactory.CreateHttpClient(new HttpClientOptions());
            _clientContent = clientFactory.CreateHttpClient(new HttpClientOptions {
                AddTokenToRequests = true, TokenRetriever = () => _options.AccessToken
            });
            _clientContentNoRedirection = clientFactory.CreateHttpClient(new HttpClientOptions {
                AllowAutoRedirect = false, AddTokenToRequests = true, TokenRetriever = () => _options.AccessToken
            });


            RequestGenerator = requestGenerator;
        }
Ejemplo n.º 16
0
 public E3SSearchService(HttpClient httpClient, IRequestGenerator requestGenerator)
 {
     _httpClient       = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     _requestGenerator = requestGenerator ?? throw new ArgumentNullException(nameof(requestGenerator));
 }
Ejemplo n.º 17
0
 public RequestIdFilter(IConsoleLogger loggingService, IRequestGenerator requestID)
 {
     this.requestId      = requestID;
     this.loggingService = loggingService;
 }
 public RequestManager(DatabaseWrapper databaseWrapper, IRequestGenerator generator)
 {
     generator.OnPOST += HandlePost;
     generator.OnGET += HandleGet;
     this.databaseWrapper = databaseWrapper;
 }
Ejemplo n.º 19
0
 public ErrorsController(IConsoleLogger loggingService, IRequestGenerator RequestIdGenerator)
 {
     this.loggingService     = loggingService;
     this.RequestIdGenerator = RequestIdGenerator;
 }