protected void given_file_system(string currentDirectory)
            {
                FileSystem = new InMemoryFileSystem
                {
                        CurrentDirectory = currentDirectory
                };
                ServiceLocator.RegisterService<IFileSystem>(FileSystem);

                Environment = new InMemoryEnvironment(FileSystem.GetDirectory(currentDirectory),
                                                      FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory));
                ServiceLocator.RegisterService<IEnvironment>(Environment);
            }
Exemplo n.º 2
0
            protected void given_file_system(string currentDirectory, params InMemoryDirectory[] directories)
            {
                FileSystem = new InMemoryFileSystem(directories)
                {
                    CurrentDirectory = currentDirectory
                };
                WrapServices.RegisterService<IFileSystem>(FileSystem);

                Environment = new InMemoryEnvironment(FileSystem.GetDirectory(currentDirectory),
                    FileSystem.GetDirectory(InstallationPaths.ConfigurationDirectory));
                WrapServices.RegisterService<IEnvironment>(Environment);
            }
            protected void given_file_system(string currentDirectory)
            {
                FileSystem = new InMemoryFileSystem
                {
                    CurrentDirectory = currentDirectory
                };
                ServiceLocator.RegisterService <IFileSystem>(FileSystem);

                Environment = new InMemoryEnvironment(FileSystem.GetDirectory(currentDirectory),
                                                      FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory));
                ServiceLocator.RegisterService <IEnvironment>(Environment);
            }
Exemplo n.º 4
0
        protected openwrap_context()
        {
            // TODO: Review if we should use the Service registry?
            RemoteRepositories = new List <IPackageRepository>();
            ConfiguredRemotes  = new RemoteRepositories();
            ServiceLocator.Clear();
            var currentDirectory = System.Environment.CurrentDirectory;

            FileSystem  = given_file_system(currentDirectory);
            Environment = new InMemoryEnvironment(
                FileSystem.GetDirectory(currentDirectory),
                FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory));
            //Environment.DescriptorFile.MustExist();
            ServiceLocator.RegisterService <IFileSystem>(FileSystem);
            ServiceLocator.RegisterService <IEnvironment>(Environment);
            ServiceLocator.RegisterService <IPackageResolver>(new StrategyResolver());
            ServiceLocator.TryRegisterService <IPackageDeployer>(() => new DefaultPackageDeployer());
            ServiceLocator.TryRegisterService <IPackageExporter>(() => new DefaultPackageExporter(new IExportProvider[] {
                new DefaultAssemblyExporter(),
                new CecilCommandExporter()
            }));
            ServiceLocator.RegisterService <ICommandRepository>(Commands);

            ServiceLocator.TryRegisterService <IPackageManager>(PackageManagerFactory());

            ServiceLocator.RegisterService <IConfigurationManager>(new DefaultConfigurationManager(Environment.ConfigurationDirectory));


            Factory           = new MemoryRepositoryFactory();
            Factory.FromToken = token => RemoteRepositories.FirstOrDefault(repo => repo.Token == token);
            RemoteFactories   = new List <IRemoteRepositoryFactory> {
                Factory
            };

            ServiceLocator.TryRegisterService <IEnumerable <IRemoteRepositoryFactory> >(() => RemoteFactories);

            ConfigurationManager = ServiceLocator.GetService <IConfigurationManager>();
            ConfigurationManager.Save(ConfiguredRemotes);

            ServiceLocator.RegisterService <IRemoteManager>(new DefaultRemoteManager(ConfigurationManager, ServiceLocator.GetService <IEnumerable <IRemoteRepositoryFactory> >()));
        }
Exemplo n.º 5
0
        protected command()
        {
            Services.ServiceLocator.Clear();
            var currentDirectory = System.Environment.CurrentDirectory;

            FileSystem  = given_file_system(currentDirectory);
            Environment = new InMemoryEnvironment(
                FileSystem.GetDirectory(currentDirectory),
                FileSystem.GetDirectory(DefaultInstallationPaths.ConfigurationDirectory));
            Environment.DescriptorFile.MustExist();
            Services.ServiceLocator.RegisterService <IFileSystem>(FileSystem);
            Services.ServiceLocator.RegisterService <IEnvironment>(Environment);
            Services.ServiceLocator.RegisterService <IPackageResolver>(new ExhaustiveResolver());
            Services.ServiceLocator.TryRegisterService <IPackageDeployer>(() => new DefaultPackageDeployer());
            Services.ServiceLocator.TryRegisterService <IPackageExporter>(() => new DefaultPackageExporter(new IExportProvider[] {
                new DefaultAssemblyExporter(),
                new CecilCommandExporter()
            }));
            Services.ServiceLocator.RegisterService <ICommandRepository>(Commands);

            Services.ServiceLocator.TryRegisterService <IPackageManager>(PackageManagerFactory());

            Services.ServiceLocator.RegisterService <IConfigurationManager>(new DefaultConfigurationManager(Environment.ConfigurationDirectory));
        }
Exemplo n.º 6
0
 public context_source_dir()
 {
     file_system = new InMemoryFileSystem();
     root        = file_system.CreateTempDirectory();
     env         = new InMemoryEnvironment(root);
 }