Example #1
0
        private static HttpClient CreateDrupalClient(DrupalConfig drupalConfig)
        {
            var handler = new HttpClientHandler
            {
                Credentials = new NetworkCredential(drupalConfig.Username, drupalConfig.Password)
            };

            return(new HttpClient(handler)
            {
                BaseAddress = new Uri(drupalConfig.BaseUrl)
            });
        }
Example #2
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            var drupalConfig = new DrupalConfig();

            Configuration = builder.Build();

            Configuration.GetSection("DrupalConfig").Bind(drupalConfig);

            DrupalModelMapper.InitializeMapper();

            using (var httpClient = CreateDrupalClient(drupalConfig))
            {
                var drupalGateway = new DrupalCatalogueGateway(httpClient);

                var catalogue = drupalGateway.RetrieveCatalogue().ToList();
            }
        }