예제 #1
0
        public IBaseCommand CreateProduct()
        {
            System.Console.WriteLine("Available records type :");
            Debug.Assert(_records.Keys != null, "_records.Keys != null");
            foreach (var recordKey in _records.Keys)
            {
                System.Console.WriteLine(recordKey);
            }

            System.Console.WriteLine("Enter record type to add it to notebook");
            IBooknoteRecord record = null;

            try
            {
                var line = System.Console.ReadLine();
                if (line == null)
                {
                    return(new NopeCommand());
                }
                var creator = _records[line];
                record = creator?.CreateProduct();
            }
            catch (KeyNotFoundException)
            {
                System.Console.WriteLine("Unknown booknote type!");
            }

            return(new AddRecordCommand(_booknote, record));
        }
예제 #2
0
 public void Add(IBooknoteRecord booknoteRecord)
 {
     _records.Add(booknoteRecord);
 }
예제 #3
0
 public AddRecordCommand([NotNull] Booknote booknote, IBooknoteRecord record)
 {
     _booknote = booknote;
     _record   = record;
 }