static void Main(string[] args) { Logging.LogProvider.SetCurrentLogProvider(new ColoredConsoleLogProvider()); DealService service = new DealService(); service.Username = "******"; var id = Guid.NewGuid().ToString(); var deal = new Deal { Id = id, Price = 500.00, Quantity = 10, Symbol = "MSFT", Time = DateTime.Now }; var result = service.Save(id, deal); Console.WriteLine(result); Console.WriteLine(); Console.WriteLine(); var vincentDeal = service.Load(id); Console.WriteLine(vincentDeal); Console.ReadLine(); }
static void Main(string[] args) { string username = Environment.UserName; Logging.LogProvider.SetCurrentLogProvider(new ColoredConsoleLogProvider()); DealService service = new DealService(username); var id = Guid.NewGuid().ToString(); var deal = Deal.Empty.With( id, 500.00, 10, "MSFT", DateTime.Now ); service.Save(id, deal); Console.WriteLine(); Console.WriteLine(); var vincentDeal = service.Load(id).DefaultIfEmpty(Deal.Empty).Single(); Console.WriteLine(vincentDeal); Console.ReadLine(); }
static void Main(string[] args) { string username = Environment.UserName; Logging.LogProvider.SetCurrentLogProvider(new ColoredConsoleLogProvider()); var serializer = new DealSerializer(); var dealStorage = new FileDealStorage(username, serializer); //var dealStorage = new SQLDealStorage("toto"); var dealCache = new DealCaching(dealStorage, dealStorage); var dealLogger = new DealServiceLogger(dealCache, dealCache); var dealService = new DealService(dealLogger, dealLogger); var id = Guid.NewGuid().ToString(); var deal = Deal.Empty.With( id, 500.00, 10, "MSFT", DateTime.Now ); dealService.Save(new Maybe <Deal>(deal)); Console.WriteLine(); Console.WriteLine(); var vincentDeal = dealService.Load(id).DefaultIfEmpty(Deal.Empty).Single(); Console.WriteLine(vincentDeal); var unknownDeal = dealService.Load("Fizz"); dealService.Save(unknownDeal); Console.ReadLine(); }
static void Main(string[] args) { string username = Environment.UserName; Logging.LogProvider.SetCurrentLogProvider(new ColoredConsoleLogProvider()); var serializer = new DealSerializer(); var dealStorage = new FileDealStorage(username,serializer); var dealCache = new DealCaching(dealStorage,dealStorage); var dealLogger = new DealServiceLogger(dealCache,dealCache); var dealService = new DealService(dealLogger,dealLogger); var id = Guid.NewGuid().ToString(); var deal = Deal.Empty.With( id, 500.00, 10, "MSFT", DateTime.Now ); dealService.Save(new Maybe<Deal>(deal)); Console.WriteLine(); Console.WriteLine(); var vincentDeal = dealService.Load(id).DefaultIfEmpty(Deal.Empty).Single(); Console.WriteLine(vincentDeal); var unknownDeal = dealService.Load("Fizz"); dealService.Save(unknownDeal); Console.ReadLine(); }
static void Main(string[] args) { string username = Environment.UserName; Logging.LogProvider.SetCurrentLogProvider(new ColoredConsoleLogProvider()); DealService service = new DealService(username); var id = Guid.NewGuid().ToString(); var deal = new Deal { Id = id, Price = 500.00, Quantity = 10, Symbol = "MSFT", Time = DateTime.Now }; service.Save(id, deal); Console.WriteLine(service.GetFileName(id)); Console.WriteLine(); Console.WriteLine(); var defaultDeal = new Deal { Id = "UnSet", Price = 0, Quantity = 0, Symbol = "UnSet", Time = DateTime.MinValue }; var vincentDeal = service.Load(id).DefaultIfEmpty(defaultDeal).Single(); Console.WriteLine(vincentDeal); Console.ReadLine(); }