public IList <ICarouselUser> GetAll()
        {
            IList <ICarouselUser> users = new List <ICarouselUser>();
            string path = this.GetActualSavePath();

            if (Directory.Exists(path))
            {
                foreach (string candidatePath in Directory.GetFiles(path))
                {
                    try
                    {
                        ICarouselUser user = this.LoadFromPath(candidatePath);
                        if (user != null)
                        {
                            users.Add(user);
                        }
                    }
                    catch (Exception)
                    {
                        // ignore
                    }
                }
                return(users);
            }
            else
            {
                throw new DirectoryNotFoundException("Unable to find the user file directory.");
            }
        }
Beispiel #2
0
 private void CarouselUserChanged(ICarouselUser carouselUser)
 {
     if (this.CarouselUser == null)
     {
         this.CarouselUser = carouselUser;
     }
     else if (carouselUser != this.CarouselUser)
     {
         // Show message to save and start editing another user?
     }
 }
        public void Save(ICarouselUser user)
        {
            string path = CarouselUserRepository.ConstructPath(this.GetActualSavePath(), user.Name);
            DataContractSerializer serializer = new DataContractSerializer(typeof(CarouselUserDTO));

            // Creates or overwrites the file at the path given.
            using (FileStream fs = File.Open(path, FileMode.Create))
            {
                serializer.WriteObject(fs, new CarouselUserDTO(user));
            }
        }
        public CarouselUserDTO(ICarouselUser user)
        {
            this.Name = user.Name;

            this.CopyPasteItems = new List <CarouselCopyPasteItemDTO>();
            foreach (ICarouselCopyPasteItem carouselCopyPasteItem in user.CopyPasteItems)
            {
                this.CopyPasteItems.Add(new CarouselCopyPasteItemDTO(carouselCopyPasteItem));
            }

            this.FileDropItems = new List <CarouselFileDropItemDTO>();
            foreach (ICarouselFileDropItem carouselFileDropItem in user.FileDropItems)
            {
                this.FileDropItems.Add(new CarouselFileDropItemDTO(carouselFileDropItem));
            }
        }
Beispiel #5
0
        public void LoadUserByName_antoine_Success()
        {
            IClipboardService       clip          = new ClipboardServiceMock();
            ICarouselColorSettings  colorSettings = new CarouselColorSettingsMock();
            ICarouselUsersSavePath  savePath      = new CarouselUsersSavePathMock();
            ICarouselUserRepository repo          = new CarouselUserRepository(savePath, clip, colorSettings);
            DataService             dataService   = new DataService(repo);
            CarouselUser            antoine       = new CarouselUser();

            antoine.Name = "antoine";
            antoine.CopyPasteItems.Add(new CarouselCopyPasteItem(clip, colorSettings)
            {
                Content     = "content 1 for antoine",
                DisplayName = "content 1"
            });

            dataService.SaveUser(antoine);
            ICarouselUser loadedUser = dataService.LoadUserByName("antoine");

            Assert.AreEqual(loadedUser.Name, "antoine");
        }
Beispiel #6
0
 public void SaveUser(ICarouselUser user)
 {
     this.carouselUserRepository.Save(user);
 }
 private void OpenEditorFor(ICarouselUser user)
 {
     new EditorWindow().Show();
 }