using System.Collections.Generic;
using System.Data.SqlClient;
using System.Threading.Tasks;
namespace ConsoleAppCheckDomain
private readonly Dictionary<string, object> _dictionary;
_dictionary = new Dictionary<string, object>();
public void SetItem(string key, object value)
_dictionary[key] = value;
public object GetItem(string key)
public string EncodedPicture { get; set; }
public async Task<Logo> GetLogo(string key, bool useHttpService = false)
if (DateTime.Now.Hour > 0 && DateTime.Now.Hour < 8 && !useHttpService)
result = (Logo)_cache.GetItem(key);
var client = new HttpClient {BaseAddress = new Uri("http://logoservice.io/")};
var response = await client.GetStringAsync("logos/" + key);
result = new Logo {EncodedPicture = response};
_cache.SetItem(key, result);
var connection = new SqlConnection("ServerName=LogoServer;Database=LogosDB");
var command = new SqlCommand("SELECT EncodedLogo FROM Logos WHERE Id = " + key);
await connection.OpenAsync();
var dbResult = await command.ExecuteReaderAsync();
result = new Logo {EncodedPicture = dbResult.GetString(0)};
Console.WriteLine(EncodedPicture);
static async Task Main(string[] args)
var logo2 = await logo.GetLogo("somekey");