Esempio n. 1
0
        public DealService(string username)
        {
            if (username == null)
            { throw new ArgumentNullException(nameof(username)); }

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

            Username = username;
            Cache = new DealCaching();
            Storage = new FileDealStorage(username);
            Serializer = new DealSerializer();
            Logger = new DealServiceLogger();
        }
        public DealService(string username)
        {
            if (username == null)
            {
                throw new ArgumentNullException(nameof(username));
            }

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

            Username   = username;
            Cache      = new DealCaching();
            Storage    = new FileDealStorage(username);
            Serializer = new DealSerializer();
            Logger     = new DealServiceLogger();
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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();
        }