void TryInitializeProjectRepository()
        {
            if (Descriptor == null || DescriptorFile == null)
            {
                return;
            }
            if (Descriptor.UseProjectRepository)
            {
                var projectRepositoryDirectory = DescriptorFile.Parent.FindProjectRepositoryDirectory();


                if (projectRepositoryDirectory != null)
                {
                    var repositoryOptions = FolderRepositoryOptions.AnchoringEnabled;
                    if (Descriptor.UseSymLinks)
                    {
                        repositoryOptions |= FolderRepositoryOptions.UseSymLinks;
                    }
                    ProjectRepository = new FolderRepository(projectRepositoryDirectory, repositoryOptions)
                    {
                        Name = "Project repository"
                    };
                }
            }
        }
Пример #2
0
        IEnumerable <ICommandOutput> CopyOpenWrap(PackageDescriptor projectDescriptor, IDirectory projectDirectory)
        {
            var packageManager = ServiceLocator.GetService <IPackageManager>();

            var repositoryOptions = FolderRepositoryOptions.AnchoringEnabled;

            if (projectDescriptor.UseSymLinks)
            {
                repositoryOptions |= FolderRepositoryOptions.UseSymLinks;
            }
            if (projectDescriptor.StorePackages)
            {
                repositoryOptions |= FolderRepositoryOptions.PersistPackages;
            }
            var projectRepository = new FolderRepository(projectDirectory.GetDirectory("wraps"), repositoryOptions)
            {
                Name = "Project repository"
            };

            packageManager.AddProjectPackage(PackageRequest.Any("openwrap"),
                                             new[] { Environment.SystemRepository },
                                             projectDescriptor,
                                             projectRepository,
                                             PackageAddOptions.Default | PackageAddOptions.Anchor | PackageAddOptions.Content).ToList();

            yield return(new Info("Project repository initialized."));
        }
Пример #3
0
        ICommandOutput SetupEnvironmentForAdd()
        {
            var directory = HostEnvironment.CurrentDirectory;

            var fromDirectory = string.IsNullOrEmpty(From) ? null : FileSystem.GetDirectory(From);

            if (fromDirectory != null && fromDirectory.Exists)
            {
                if (SysPath.GetExtension(Name).EqualsNoCase(".wrap") &&
                    SysPath.IsPathRooted(Name) &&
                    FileSystem.GetDirectory(SysPath.GetDirectoryName(Name)) != fromDirectory)
                {
                    return(new Error("You provided both -From and -Name, but -Name is a path. Try removing the -From parameter."));
                }
                directory = fromDirectory;
                _userSpecifiedRepository = new FolderRepository(directory, FolderRepositoryOptions.Default);
            }


            if (SysPath.GetExtension(Name).EqualsNoCase(".wrap") && directory.GetFile(SysPath.GetFileName(Name)).Exists)
            {
                var originalName = Name;
                Name    = PackageNameUtility.GetName(SysPath.GetFileNameWithoutExtension(Name));
                Version = PackageNameUtility.GetVersion(SysPath.GetFileNameWithoutExtension(originalName)).ToString();

                return(new Warning("The requested package contained '.wrap' in the name. Assuming you pointed to a file name and meant a package named '{0}' with version qualifier '{1}'.",
                                   Name,
                                   Version));
            }
            return(null);
        }
Пример #4
0
        static UserRepository()
        {
            if (!Directory.Exists(_userWrapsPath))
                Directory.CreateDirectory(_userWrapsPath);

            Current = new FolderRepository(_userWrapsPath);
        }
        public void Initialize()
        {
            FileSystem = LocalFileSystem.Instance;
            SystemRepositoryDirectory = SystemRepositoryDirectory ?? FileSystem.GetDirectory(DefaultInstallationPaths.SystemRepositoryDirectory);
            var descriptors = new PackageDescriptorReader().ReadAll(CurrentDirectory);

            if (descriptors.ContainsKey(string.Empty))
            {
                DescriptorFile = descriptors[string.Empty].File;
                Descriptor     = descriptors[string.Empty].Value;
            }

            ScopedDescriptors = descriptors;
            TryInitializeProjectRepository();

            CurrentDirectoryRepository = new CurrentDirectoryRepository();

            SystemRepository = new FolderRepository(SystemRepositoryDirectory)
            {
                Name = "System repository"
            };

            ConfigurationDirectory = FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory);

            RemoteRepositories   = new RemoteRepositoryBuilder(FileSystem, Services.ServiceLocator.GetService <IConfigurationManager>()).GetConfiguredPackageRepositories().ToList();
            ExecutionEnvironment = new ExecutionEnvironment
            {
                Platform = IntPtr.Size == 4 ? "x86" : "x64",
                Profile  = Environment.Version.Major >= 4 ? "net40" : "net35"
            };
        }
Пример #6
0
        public void ApplyDifferenceCreateFolderTopFolder()
        {
            string           folderToAdd      = "Nagesh";
            DbRepository     dbRepository     = new DbRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Create("", folderToAdd, true);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "");
            bool isFound = false;

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == folderToAdd)
                {
                    isFound = true;
                    break;
                }
            }
            if (!isFound)
            {
                Assert.Fail($"{folderToAdd} was supposed to be present but not found");
            }
        }
Пример #7
0
        public void CreateFolderTest()
        {
            FolderRepository folderRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");

            folderRepository.CreateFolder("Folder1", "Bhanu");

            Storage input = new Storage
            {
                Name     = "Bhanu",
                IsFolder = true
            };

            Assert.IsTrue(folderRepository.Exist("Folder1", input), "Folder not in the list");

            //List<Storage> storageList = folderRepository.PopulateStorageList("Folder1");
            //bool isPresent = false;
            //foreach (Storage storage in storageList)
            //{
            //    if ((storage.IsFolder) && (storage.Name == "Dutta"))
            //    {
            //        isPresent = true;
            //        break;
            //    }
            //}
            //Assert.IsTrue(isPresent, "Dutta is not in the list");
        }
Пример #8
0
        public void DeleteFolder()
        {
            FolderRepository folderRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");
            //folderRepository.Create("Folder1", "Bhanu", true);
            List <Storage> storageList =
                folderRepository.PopulateStorageList("Folder1");

            folderRepository.Delete("Folder1", true);

            bool isPresent = true;

            foreach (Storage storage in storageList)
            {
                if ((storage.IsFolder) && (storage.Name == "Folder1"))
                {
                    isPresent = false;
                    break;
                }
            }
            Assert.IsTrue(isPresent, "Folder1 is not in the list");

            //Storage input = new Storage
            //{
            //    Name = "Nagesh",
            //    IsFolder = true
            //};

            //Assert.IsTrue(folderRepository.Exist("Folder1", input), "Folder not in the list");
            //Assert.Inconclusive("Not Implemented Yet!");
        }
Пример #9
0
 public DocumentController(FolderRepository folderRepository,
                           DocumentRepository documentRepository, UserRepository userRepository) :
     base(userRepository)
 {
     this.folderRepository   = folderRepository;
     this.documentRepository = documentRepository;
 }
Пример #10
0
        public static bool Install(string basePath, string repositoryHost, string programName, out string message)
        {
            message = "";
            RepositoryInfo repo = new RepositoryInfo(repositoryHost);

            if (repo.RepositoryType == Hosts.HostType.None)
            {
            }
            IRepository repository;

            switch (repo.RepositoryType)
            {
            case Hosts.HostType.HTTP:
                repository = new HTTPRepository(repositoryHost);
                break;

            case Hosts.HostType.SharedFolder:
            case Hosts.HostType.LocalFolder:
                repository = new FolderRepository(repositoryHost);
                break;

            default:
                message = Strings.Get(StringName.OptionErrorRepositoryType, "REPO", repositoryHost);
                return(false);
            }

            return(true);
            //TODO: Implementar a instalação de um programa a partir de um repositório
        }
Пример #11
0
        public void Initialize()
        {
            var mockDb = new MockDatabase();

            InitMockData.InitData(mockDb);
            _folder = new FolderRepository(mockDb);
        }
Пример #12
0
        public void ApplyDifferenceDeleteFolderTopFolder()
        {
            ApplyDifferenceCreateFolderTopFolder();
            string           folderToDelete   = "Nagesh";
            DbRepository     dbRepository     = new DbRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Delete($@"{folderToDelete}", true);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "");

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == folderToDelete)
                {
                    Assert.Fail($"{folderToDelete} should not show up as it should be deleted");
                }
            }
        }
Пример #13
0
        public void ApplyDifferenceDeleteFileTopFolder()
        {
            //ApplyDifferenceCreateFileTopFolder();
            string           fileToDelete     = "File1.txt";
            DbRepository     dbRepository     = new DbRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Delete(fileToDelete, false);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "");

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == fileToDelete)
                {
                    Assert.Fail($"The file {fileToDelete} should be deleted but it is still present");
                }
            }
        }
Пример #14
0
        public async Task <SBRecoverFolder> ObtenerListaCarpetasAsync()
        {
            var FolderRepository = new FolderRepository();
            var procesor         = new Procesor(FolderRepository);

            return(await procesor.GetRecoverFolder());
        }
        public void SetUp()
        {
            var data = new List <Folder>
            {
                new Folder {
                    Id = 1, Name = "ObligatorioBD"
                },
                new Folder {
                    Id = 2, Name = "ObligatorioIngSoft"
                },
                new Folder {
                    Id = 3, Name = "ObligatorioDisAp"
                }
            }.AsQueryable();

            //mockeo tabla de vehiculos
            mockSet = new Mock <DbSet <Folder> >();
            mockSet.As <IQueryable <Folder> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Folder> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Folder> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Folder> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            mockSet.Setup(m => m.Find(It.IsAny <object[]>())).Returns <object[]>(pk => data.FirstOrDefault(d => d.Id == (int)pk[0]));

            //mockeo contexto y lo hago apuntar al mock de mi db
            DbOptions   = new DbContextOptions <TwoDriveContext>();
            mockContext = new Mock <TwoDriveContext>(DbOptions);
            mockContext.Setup(v => v.Folders).Returns(mockSet.Object);

            folderRepository = new FolderRepository(mockContext.Object);
        }
Пример #16
0
        public void ApplyDifferenceCreateFile()
        {
            string           fileToAdd        = "Bhanu.txt";
            DbRepository     dbRepository     = new DbRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Create("Folder1", fileToAdd, false);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "Folder1");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "Folder1",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "Folder1");
            bool isFound = false;

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == fileToAdd)
                {
                    Assert.AreEqual(false, myStorage.IsFolder, "Incorrect type");
                    isFound = true;
                }
            }
            Assert.IsTrue(isFound, $"{fileToAdd} cannot be found in the db");
        }
Пример #17
0
        public async Task <bool> CrearNuevaCarpetaAsync(string nombreCarpeta)
        {
            var folderRepository = new FolderRepository();
            var serializeModel   = new SerializeModel();
            var procesor         = new Procesor(serializeModel, folderRepository);

            return(await procesor.CreateNewFolderAsync(nombreCarpeta));
        }
Пример #18
0
 public void CreateFile()
 {
     FolderRepository uploadRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");
     Stream           fileStream       = File.OpenRead($@"{Utils.GetSetupDir()}\UploadFolder\file1.txt");
     DateTime         createdTime      = uploadRepository.CreateFile("Folder1", fileStream, "Dutta.txt");
     FolderRepository dbRepository     = new FolderRepository($@"{Utils.GetSetupDir()}\DbFolder");
     List <Storage>   difference       = Utils.Compare(dbRepository, uploadRepository, "Folder1");
 }
Пример #19
0
 public FolderCRUDService(Connection connection)
     : base(connection)
 {
     _folderValidationService = new FolderValidationService(connection);
     _folderRepository        = new FolderRepository(connection);
     _compositeTypeRepository = new CompositeTypeRepository(connection);
     _presetRepository        = new PresetRepository(connection);
 }
Пример #20
0
        public void PopulateStorage()
        {
            FolderRepository folderRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");
            List <Storage>   storageList      =
                folderRepository.PopulateStorageList("Folder1");

            Assert.AreEqual(2, storageList.Count, "There should only be two elements in the list");
        }
Пример #21
0
        public void GetAll()
        {
            const int expectedLength = folderCount;
            var       repo           = new FolderRepository(_context);
            var       res            = repo.GetAll();

            Assert.Equal(expectedLength, res.Count());
        }
Пример #22
0
        public void FindById()
        {
            const string expectedName = "Name5";
            var          repo         = new FolderRepository(_context);
            var          res          = repo.Find(5);

            Assert.Equal(expectedName, res.Name);
        }
 public FolderValidationService(Connection connection)
     : base(connection)
 {
     _genericRepository              = new GenericRepository(connection);
     _folderRepository               = new FolderRepository(connection);
     _compositeTypeRepository        = new CompositeTypeRepository(connection);
     _compositeTypeValidationService = new CompositeTypeValidationService(connection);
 }
Пример #24
0
 void EnsureWrapRepositoryIsInitialized()
 {
     if (PackageRepository != null)
     {
         Log.LogMessage(MessageImportance.Low, "Project repository found.");
         return;
     }
     PackageRepository = new FolderRepository(WrapsDirectoryPath);
 }
Пример #25
0
        public FileManager(ObservableSettings settings, RiZhi log)
        {
            _log = log ?? throw new ArgumentNullException(nameof(log));

            _fileSystem = new FolderRepository(settings, log);
            _db         = new DatabaseRepository(log);

            _reader = new ReplayReader(log);
        }
 public GenerateCSVService(Connection connection)
     : base(connection)
 {
     _folderRepository                 = new FolderRepository(connection);
     _compositeTypeRepository          = new CompositeTypeRepository(connection);
     _compositeTypeElementRepository   = new CompositeTypeElementRepository(connection);
     _presetRepository                 = new PresetRepository(connection);
     _compositePresetElementRepository = new CompositePresetElementRepository(connection);
 }
Пример #27
0
 void EnsurePackageRepositoryIsInitialized()
 {
     if (PackageRepository != null)
     {
         Log.LogMessage(MessageImportance.Low, "No project repository found.");
         return;
     }
     PackageRepository = new FolderRepository(WrapsDirectoryPath, FolderRepositoryOptions.SupportLocks);
     PackageRepository.RefreshPackages();
 }
Пример #28
0
        public void RemoveRemovedFolder()
        {
            const int itemId         = 1;
            const int expectedLength = folderCount - 1;
            var       repo           = new FolderRepository(_context);

            repo.Remove(itemId);
            var res = repo.GetAll();

            Assert.Equal(expectedLength, res.Count());
        }
Пример #29
0
        public void ShowDifferenceDeleteFolder()
        {
            DbRepository     dbRepository     = new DbRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder\Folder1");

            uploadRepository.Delete("Folder2", true);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "Folder1");
            Storage        storage = output[0];

            Assert.AreEqual(true, storage.IsFolder, "Incorrect type");
            Assert.AreEqual("Folder2", storage.Name, "Incorrect Name");
            Assert.AreEqual(Constants.Action.Delete, storage.Action, "Incorrect Action");
        }
Пример #30
0
        public void ShowDifferenceCreateFile()
        {
            DbRepository     dbRepository     = new DbRepository("DbFolder");
            FolderRepository uploadRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Create("Folder1", "XXX.txt", false);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "Folder1");
            Storage        storage = output[0];

            Assert.AreEqual(false, storage.IsFolder, "Incorrect type");
            Assert.AreEqual("XXX.txt", storage.Name, "Incorrect Name");
            Assert.AreEqual(Constants.Action.Create, storage.Action, "Incorrect Action");
        }
Пример #31
0
            protected void given_folder_repository_with_module(string packageName)
            {
                FileSystem     = LocalFileSystem.Instance;
                RepositoryPath = FileSystem.CreateTempDirectory();
                Packager.NewWithDescriptor(
                    RepositoryPath.GetFile(packageName + "-1.0.0.wrap"),
                    packageName,
                    "1.0.0",
                    "depends: nhibernate-core = 2.1"
                    );

                Repository = new FolderRepository(RepositoryPath);
            }
Пример #32
0
 public ServiceSeat(
     SeatHistoryRepository seathistRepo,
     SeatRepository seatRepo,
     AuthRepository authRepo,
     UserRepository userRepo,
     FolderRepository folderRepo,
     UnitOfWork unit)
     : base(unit)
 {
     this.seathist_repo = seathistRepo;
     this.seat_repo = seatRepo;
     this.auth_repo = authRepo;
     this.user_repo = userRepo;
     this.folder_repo = folderRepo;
 }
Пример #33
0
            protected void given_folder_repository_with_module()
            {
                FileSystem = LocalFileSystem.Instance;
                RepositoryPath = FileSystem.CreateTempDirectory();
                PackageBuilder.NewWithDescriptor(
                    RepositoryPath.GetFile("test-module-1.0.0.wrap"),
                    "test-module",
                    "1.0.0",
                    "depends: nhibernate-core = 2.1"
                    );

                Repository = new FolderRepository(RepositoryPath);
            }
Пример #34
0
 protected void given_folder_repository()
 {
     RepositoryPath = Directory.CreateDirectory(FileSystem.CombinePaths(
         Path.GetTempPath(),
         Path.GetRandomFileName()));
     var wrapFile = TestFiles.test_module_1_0_0;
     using(var file = File.Create(Path.Combine(RepositoryPath.FullName,"test-module-1.0.0.wrap")))
     {
         file.Write(wrapFile,0, wrapFile.Length);
         file.Flush();
     }
     Repository = new FolderRepository(RepositoryPath.FullName);
 }