Beispiel #1
0
        private void CreateNewPot(CreatePotRequest request)
        {
            Pot newPot = new Pot
            {
                Name = request.Name,
                Path = request.Path
            };

            potRepository.Add(newPot);
        }
        protected override void Handle(ImportSnapshotRequest request)
        {
            //ISnapshotReader reader = null;
            //ISnapshotWriter writer = null;

            //while (reader.MoveNext())
            //{
            //    switch (reader.CurrentItemType)
            //    {
            //        case SnapshotItemType.None:
            //            break;

            //        case SnapshotItemType.SerializerId:
            //            writer.WriteSerializerId(reader.ReadSerializerId());
            //            break;

            //        case SnapshotItemType.OriginalPath:
            //            writer.WriteOriginalPath(reader.ReadOriginalPath());
            //            break;

            //        case SnapshotItemType.CreationTime:
            //            writer.WriteCreationTime(reader.ReadCreationTime());
            //            break;

            //        case SnapshotItemType.FileCollection:
            //            IEnumerable<HFile> files = reader.ReadFiles();

            //            foreach (HFile file in files)
            //                writer.Add(file);
            //            break;

            //        case SnapshotItemType.DirectoryCollection:
            //            IEnumerable<HDirectoryReader> directories = reader.ReadDirectories();

            //            foreach (HDirectory directory in directories)
            //                writer.Add(directory);
            //            break;
            //    }
            //}



            Snapshot snapshot = potImportExport.ReadSnapshot(request.FilePath);

            Pot pot = potRepository.Get(request.PotName);

            if (pot == null)
            {
                pot = new Pot
                {
                    Name = request.PotName,
                    Path = snapshot.OriginalPath
                };

                potRepository.Add(pot);
            }
            else
            {
                if (pot.Path != snapshot.OriginalPath)
                {
                    throw new Exception("The url of the imported snapshot is different than the one of the pot.");
                }
            }

            snapshotRepository.Add(request.PotName, snapshot);
        }