public DiagnosticController(IContentItemRepository repository, IHost host, IDefinitionManager definitions,
            ILinkGenerator linkGenerator, IUrlParser parser, DatabaseSection config, IFlushable flushable, IReplicationStorage repstore, 
            IFileSystemFactory fileSystemFactory)
        {
            _repository = repository;
            _host = host;
            _definitions = definitions;
            _linkGenerator = linkGenerator;
            _parser = parser;
            _flushable = flushable;
            _tablePrefix = config.TablePrefix;

            _repstore = repstore;

            if (_forceWriteLockManager != null) return;

            // Create Force Write Lock Manager
            var storageConfig = (FileSystemNamespace) Enum.Parse(typeof (FileSystemNamespace),
                ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ??
                "ReplicationStorageDebug");

            var fileSystem = fileSystemFactory.Create(storageConfig);
            _forceWriteLockManager = new ReplicationForceWriteLockManager(fileSystem);
            _writeLockManager = new ReplicationWriteLockManager(fileSystem);
        }
        public async Task Test(string input, string appManifestPropertyValue, string expectedFilePath)
        {
            var inputTree = ProjectTreeParser.Parse(input);

            var projectTreeProvider = IProjectTreeProviderFactory.Create(@"C:\Foo\Properties", (root, path) =>
            {
                root.TryFindImmediateChild(Path.GetFileName(path), out var node);
                return(node);
            });
            var projectTree         = IPhysicalProjectTreeFactory.Create(currentTree: inputTree, provider: projectTreeProvider);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);
            var specialFilesManager = ISpecialFilesManagerFactory.Create();

            var properties = ProjectPropertiesFactory.Create(UnconfiguredProjectFactory.Create(), new PropertyPageData
            {
                Category     = ConfigurationGeneralBrowseObject.SchemaName,
                PropertyName = ConfigurationGeneralBrowseObject.ApplicationManifestProperty,
                Value        = appManifestPropertyValue
            });
            var provider = new AppManifestSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager, properties);
            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.CreateIfNotExist);

            Assert.Equal(expectedFilePath, filePath);
        }
예제 #3
0
        public DiagnosticController(IContentItemRepository repository, IHost host, IDefinitionManager definitions,
                                    ILinkGenerator linkGenerator, IUrlParser parser, DatabaseSection config, IFlushable flushable, IReplicationStorage repstore,
                                    IFileSystemFactory fileSystemFactory)
        {
            _repository    = repository;
            _host          = host;
            _definitions   = definitions;
            _linkGenerator = linkGenerator;
            _parser        = parser;
            _flushable     = flushable;
            _tablePrefix   = config.TablePrefix;

            _repstore = repstore;

            if (_forceWriteLockManager != null)
            {
                return;
            }

            // Create Force Write Lock Manager
            var storageConfig = (FileSystemNamespace)Enum.Parse(typeof(FileSystemNamespace),
                                                                ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ??
                                                                "ReplicationStorageDebug");

            var fileSystem = fileSystemFactory.Create(storageConfig);

            _forceWriteLockManager = new ReplicationForceWriteLockManager(fileSystem);
            _writeLockManager      = new ReplicationWriteLockManager(fileSystem);
        }
        public async Task CreateFile_NotInSync(string input, string expected, bool fileExistsOnDisk, string expectedFilePath)
        {
            var inputTree    = ProjectTreeParser.Parse(input);
            var expectedTree = ProjectTreeParser.Parse(expected);

            var projectTreeProvider = new ProjectTreeProvider();
            var projectTree         = IPhysicalProjectTreeFactory.Create(provider: projectTreeProvider, currentTree: inputTree);
            var sourceItemsProvider = IProjectItemProviderFactory.CreateWithAdd(inputTree);
            var fileSystem          = IFileSystemFactory.Create(path => fileExistsOnDisk,
                                                                path =>
            {
                // Verify that file is created on disk.
                Assert.False(fileExistsOnDisk);
                Assert.Equal(expectedFilePath, path);
                return(null);
            });

            var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(@"C:\Foo\Properties");

            var provider = new SettingsFileSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager);
            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.CreateIfNotExist);

            Assert.Equal(expectedFilePath, filePath);
            AssertAreEquivalent(expectedTree, inputTree);
        }
        public void GlobalJsonRemover_NoJson_DoesntCrash()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var solution    = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback);
            var dteSolution = SolutionFactory.ImplementFindProjectItem(path =>
            {
                Assert.Equal(Path.Combine(Directory, "global.json"), path);
                return(null);
            });
            var dte = DteFactory.ImplementSolution(() => dteSolution);

            var serviceProvider = IServiceProviderFactory.ImplementGetService(t =>
            {
                if (typeof(SVsSolution) == t)
                {
                    return(solution);
                }

                if (typeof(DTE) == t)
                {
                    return(dte);
                }

                Assert.False(true);
                throw new InvalidOperationException();
            });

            var remover = new GlobalJsonRemover(serviceProvider, IFileSystemFactory.Create());

            GlobalJsonRemover.Remover = remover;
            Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0));
        }
        public void GlobalJsonSetup_ExistingRemover_ReturnsSameRemover()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var remover = new GlobalJsonRemover(IServiceProviderFactory.Create(), IFileSystemFactory.Create());

            GlobalJsonRemover.Remover = remover;
            Assert.False(new GlobalJsonRemover.GlobalJsonSetup().SetupRemoval(IVsSolutionFactory.Create(),
                                                                              IServiceProviderFactory.Create(), IFileSystemFactory.Create()));
            Assert.True(ReferenceEquals(remover, GlobalJsonRemover.Remover));
        }
예제 #7
0
        public void Constructor_NullProjectTreeService_ThrowsArgumentNullException()
        {
            var fileSystem          = IFileSystemFactory.Create();
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var specialFilesManager = ISpecialFilesManagerFactory.Create();

            Assert.Throws <ArgumentNullException>("projectTree", () =>
            {
                new AppSettingsSpecialFileProvider(null !, sourceItemsProvider, null, fileSystem, specialFilesManager);
            });
        public void Constructor_NullSourceItemsProvider_ThrowsArgumentNullException()
        {
            var projectTree         = IPhysicalProjectTreeFactory.Create();
            var fileSystem          = IFileSystemFactory.Create();
            var specialFilesManager = ISpecialFilesManagerFactory.Create();

            Assert.Throws <ArgumentNullException>("sourceItemsProvider", () =>
            {
                new SettingsFileSpecialFileProvider(projectTree, null, null, fileSystem, specialFilesManager);
            });
        }
 public void NullShellUtilities_Throws()
 {
     Assert.Throws <ArgumentNullException>("shellUtilities", () => new TempFileTextBufferManager(
                                               UnconfiguredProjectFactory.Create(),
                                               IProjectXmlAccessorFactory.Create(),
                                               IVsEditorAdaptersFactoryServiceFactory.Create(),
                                               ITextDocumentFactoryServiceFactory.Create(),
                                               null,
                                               IFileSystemFactory.Create(),
                                               IProjectThreadingServiceFactory.Create(),
                                               IServiceProviderFactory.Create()));
 }
        private PhysicalProjectTreeStorage CreateInstance(IProjectTreeService treeService = null, IProjectTreeProvider treeProvider = null, IFileSystem fileSystem = null, IFolderManager folderManager = null, UnconfiguredProject project = null)
        {
            treeService = treeService ?? IProjectTreeServiceFactory.Create(ProjectTreeParser.Parse("Root"));
            treeProvider = treeProvider ?? IProjectTreeProviderFactory.Create();
            fileSystem = fileSystem ?? IFileSystemFactory.Create();
            folderManager = folderManager ?? IFolderManagerFactory.Create();
            project = project ?? UnconfiguredProjectFactory.Create();

            return new PhysicalProjectTreeStorage(new Lazy<IProjectTreeService>(() => treeService),
                                                  new Lazy<IProjectTreeProvider>(() => treeProvider),
                                                  new Lazy<IFileSystem>(() => fileSystem),
                                                  ActiveConfiguredProjectFactory.ImplementValue(() => folderManager),
                                                  project);
        }
        public async Task FindFile_NodeNotInSync(string input, bool fileExistsOnDisk, string expectedFilePath)
        {
            var inputTree = ProjectTreeParser.Parse(input);

            var projectTreeService  = IProjectTreeServiceFactory.Create(inputTree);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => fileExistsOnDisk);

            var provider = new SettingsFileSpecialFileProvider(projectTreeService, sourceItemsProvider, null, fileSystem);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.FullPath);

            Assert.Equal(expectedFilePath, filePath);
        }
        public async Task FindFile_FromRoot(string input, string expectedFilePath)
        {
            var inputTree = ProjectTreeParser.Parse(input);

            var projectTreeService  = IProjectTreeServiceFactory.Create(inputTree);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);

            var provider = new AppConfigFileSpecialFileProvider(projectTreeService, sourceItemsProvider, null, fileSystem);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppConfig, SpecialFileFlags.FullPath);

            Assert.Equal(expectedFilePath, filePath);
        }
        public async Task FindFile_FromAppDesignerFolder(string input, string expectedFilePath)
        {
            var inputTree           = ProjectTreeParser.Parse(input);
            var projectTreeProvider = new ProjectTreeProvider();
            var projectTree         = IPhysicalProjectTreeFactory.Create(currentTree: inputTree, provider: projectTreeProvider);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);
            var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(@"C:\Foo\Properties");

            var provider = new SettingsFileSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.FullPath);

            Assert.Equal(expectedFilePath, filePath);
        }
        private PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger     = IProjectLoggerFactory.Create();
            IFileSystem    fileSystem = IFileSystemFactory.Create();

            return(new PackageRestoreDataSource(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger));
        }
        private static DotNetCoreProjectCompatibilityDetector CreateCompatibilityDetector(out IDialogServices dialogServices,
                                                                                          string?versionDataString      = null,
                                                                                          Version?vsVersion             = null,
                                                                                          bool isSolutionOpen           = false,
                                                                                          bool hasNewProjects           = false,
                                                                                          bool usingPreviewSDK          = false,
                                                                                          bool isCapabilityMatch        = true,
                                                                                          string targetFrameworkMoniker = ".NETCoreApp,Version=v3.0")
        {
            dialogServices = IDialogServicesFactory.Create();
            var additionalReference = dialogServices;
            var projectProperties   = IProjectPropertiesFactory.CreateWithPropertyAndValue("TargetFrameworkMoniker", targetFrameworkMoniker);
            var propertiesProvider  = IProjectPropertiesProviderFactory.Create(commonProps: projectProperties);
            var project             = ConfiguredProjectFactory.Create(services: ConfiguredProjectServicesFactory.Create(projectPropertiesProvider: propertiesProvider));
            var scope                  = hasNewProjects ? IProjectCapabilitiesScopeFactory.Create(new[] { ProjectCapability.DotNet, ProjectCapability.PackageReferences }) : null;
            var projectAccessor        = new Lazy <IProjectServiceAccessor>(() => IProjectServiceAccessorFactory.Create(scope, project));
            var lazyDialogServices     = new Lazy <IDialogServices>(() => additionalReference);
            var threadHandling         = new Lazy <IProjectThreadingService>(() => IProjectThreadingServiceFactory.Create(verifyOnUIThread: false));
            var vsShellUtilitiesHelper = new Lazy <IVsShellUtilitiesHelper>(() => IVsShellUtilitiesHelperFactory.Create(string.Empty, vsVersion ?? new Version("16.1")));
            var fileSystem             = new Lazy <IFileSystem>(() => IFileSystemFactory.Create(existsFunc: x => true, readAllTextFunc: x => versionDataString ?? defaultVersionDataString));
            var httpClient             = new Lazy <IHttpClient>(() => IHttpClientFactory.Create(versionDataString ?? defaultVersionDataString));
            var vsUIShellService       = IVsServiceFactory.Create <SVsUIShell, IVsUIShell>(Mock.Of <IVsUIShell>());
            var settingsManagerService = IVsServiceFactory.Create <SVsSettingsPersistenceManager, ISettingsManager>(Mock.Of <ISettingsManager>());
            var vsSolutionService      = IVsServiceFactory.Create <SVsSolution, IVsSolution>(IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(1, isFullyLoaded: isSolutionOpen));
            var vsAppIdService         = IVsServiceFactory.Create <SVsAppId, IVsAppId>(Mock.Of <IVsAppId>());
            var vsShellService         = IVsServiceFactory.Create <SVsShell, IVsShell>(Mock.Of <IVsShell>());

            var compatibilityDetector = new TestDotNetCoreProjectCompatibilityDetector(projectAccessor,
                                                                                       lazyDialogServices,
                                                                                       threadHandling,
                                                                                       vsShellUtilitiesHelper,
                                                                                       fileSystem,
                                                                                       httpClient,
                                                                                       vsUIShellService,
                                                                                       settingsManagerService,
                                                                                       vsSolutionService,
                                                                                       vsAppIdService,
                                                                                       vsShellService,
                                                                                       hasNewProjects,
                                                                                       usingPreviewSDK,
                                                                                       isCapabilityMatch);

            return(compatibilityDetector);
        }
        public ReplicationStorageFileSystemN2(ContentActivator activator, IFileSystemFactory fsfactory, IDefinitionManager definitions, IPersister persister)
        {
            _activator = activator;
            _definitions = definitions;
            _persister = persister;

            string value = (ConfigurationManager.AppSettings["XmlReplication"] ?? "false").ToLowerInvariant();
            if (value.Equals("slave") || value.Equals("master"))
            {
                // only initialize if replication is active
                var storageConfig = (FileSystemNamespace) Enum.Parse(typeof (FileSystemNamespace),
                               ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ?? "ReplicationStorageDebug");

                _fs = fsfactory.Create(storageConfig);

                if (_fs.GetType().Name.Contains("Azure"))
                    _path = "/_Xml_Sync_"; // TODO maybe should add TablePrefix?
            }
        }
        public async Task GetFile_WhenNoAppDesigner_ReturnsPathUnderProjectRoot()
        {
            var inputTree = ProjectTreeParser.Parse(@"
Root (flags: {ProjectRoot}), FilePath: ""C:\Foo\testing.csproj""
    Properties (flags: {Folder}), FilePath: ""C:\Foo\Properties""
        Settings.settings, FilePath: ""C:\Foo\Properties\Settings.settings""");

            var projectTreeProvider = new ProjectTreeProvider();
            var projectTree         = IPhysicalProjectTreeFactory.Create(currentTree: inputTree, provider: projectTreeProvider);
            var sourceItemsProvider = IProjectItemProviderFactory.Create();
            var fileSystem          = IFileSystemFactory.Create(path => true);
            var specialFilesManager = ISpecialFilesManagerFactory.ImplementGetFile(null); // No AppDesigner

            var provider = new SettingsFileSpecialFileProvider(projectTree, sourceItemsProvider, null, fileSystem, specialFilesManager);

            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.FullPath);

            Assert.Equal(@"C:\Foo\Settings.settings", filePath);
        }
        public void GlobalJsonRemover_AfterRemoval_UnadvisesEvents()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            var globalJsonPath = Path.Combine(Directory, "global.json");
            var solution       = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback);
            var projectItem    = ProjectItemFactory.Create();
            var dteSolution    = SolutionFactory.ImplementFindProjectItem(path =>
            {
                Assert.Equal(globalJsonPath, path);
                return(projectItem);
            });
            var dte = DteFactory.ImplementSolution(() => dteSolution);

            var serviceProvider = IServiceProviderFactory.ImplementGetService(t =>
            {
                if (typeof(SVsSolution) == t)
                {
                    return(solution);
                }

                if (typeof(DTE) == t)
                {
                    return(dte);
                }

                Assert.False(true);
                throw new InvalidOperationException();
            });

            var fileSystem = IFileSystemFactory.Create();

            fileSystem.Create(globalJsonPath);

            var remover = new GlobalJsonRemover(serviceProvider, fileSystem)
            {
                SolutionCookie = 1234
            };

            GlobalJsonRemover.Remover = remover;
            Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0));
            Mock.Get(solution).Verify(s => s.UnadviseSolutionEvents(1234), Times.Once);
        }
예제 #19
0
        private static PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectDiagnosticOutputService logger = IProjectDiagnosticOutputServiceFactory.Create();
            IFileSystem fileSystem = IFileSystemFactory.Create();
            var         projectDependentFileChangeNotificationService = IProjectDependentFileChangeNotificationServiceFactory.Create();

            return(new PackageRestoreDataSource(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger,
                       projectDependentFileChangeNotificationService));
        }
        public async Task CreateFile_InRootFolder(string input, string expected, string expectedFilePath)
        {
            var inputTree    = ProjectTreeParser.Parse(input);
            var expectedTree = ProjectTreeParser.Parse(expected);

            var projectTreeService  = IProjectTreeServiceFactory.Create(inputTree);
            var sourceItemsProvider = IProjectItemProviderFactory.CreateWithAdd(inputTree);
            var fileSystem          = IFileSystemFactory.Create(path => false,
                                                                path =>
            {
                // Verify that file is created on disk.
                Assert.Equal(expectedFilePath, path);
                return(null);
            });

            var provider = new AppConfigFileSpecialFileProvider(projectTreeService, sourceItemsProvider, null, fileSystem);
            var filePath = await provider.GetFileAsync(SpecialFiles.AppConfig, SpecialFileFlags.CreateIfNotExist);

            Assert.Equal(expectedFilePath, filePath);
            AssertAreEquivalent(expectedTree, inputTree);
        }
        private PackageRestoreServiceInstance CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create();
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectThreadingService         threadingService = IProjectThreadingServiceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger         = IProjectLoggerFactory.Create();
            IFileSystem    fileSystem     = IFileSystemFactory.Create();
            var            broadcastBlock = DataflowBlockSlim.CreateBroadcastBlock <IProjectVersionedValue <RestoreData> >();

            return(new PackageRestoreServiceInstance(
                       project,
                       dataSource,
                       threadingService,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger,
                       broadcastBlock));
        }
        private static PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.CreateWithActiveConfiguredProjectProvider(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectDiagnosticOutputService logger = IProjectDiagnosticOutputServiceFactory.Create();
            IFileSystem fileSystem = IFileSystemFactory.Create();
            var         vsSolutionRestoreService4    = IVsSolutionRestoreService4Factory.ImplementRegisterRestoreInfoSourceAsync();
            var         sharedJoinableTaskCollection = new PackageRestoreSharedJoinableTaskCollection(IProjectThreadingServiceFactory.Create());

            return(new PackageRestoreDataSourceMocked(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       logger,
                       vsSolutionRestoreService4,
                       sharedJoinableTaskCollection));
        }
        public async Task CreateFile_CallTemplateProvider(string input, string expected, string expectedFilePath)
        {
            var inputTree    = ProjectTreeParser.Parse(input);
            var expectedTree = ProjectTreeParser.Parse(expected);

            var projectTreeService  = IProjectTreeServiceFactory.Create(inputTree);
            var sourceItemsProvider = IProjectItemProviderFactory.CreateWithAdd(inputTree);
            var fileSystem          = IFileSystemFactory.Create(path => false,
                                                                path =>
            {
                // Verify that file is created on disk.
                Assert.False(true, "File system create shouldn't have been called directly.");
                return(null);
            });
            var templateProvider = new Lazy <ICreateFileFromTemplateService>(() => ICreateFileFromTemplateServiceFactory.Create());

            var provider = new SettingsFileSpecialFileProvider(projectTreeService, sourceItemsProvider, templateProvider, fileSystem);
            var filePath = await provider.GetFileAsync(SpecialFiles.AppSettings, SpecialFileFlags.CreateIfNotExist);

            Assert.Equal(expectedFilePath, filePath);
            AssertAreEquivalent(expectedTree, inputTree);
        }
        public ReplicationStorageFileSystemN2(ContentActivator activator, IFileSystemFactory fsfactory, IDefinitionManager definitions, IPersister persister)
        {
            _activator   = activator;
            _definitions = definitions;
            _persister   = persister;

            string value = (ConfigurationManager.AppSettings["XmlReplication"] ?? "false").ToLowerInvariant();

            if (value.Equals("slave") || value.Equals("master"))
            {
                // only initialize if replication is active
                var storageConfig = (FileSystemNamespace)Enum.Parse(typeof(FileSystemNamespace),
                                                                    ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ?? "ReplicationStorageDebug");

                _fs = fsfactory.Create(storageConfig);

                if (_fs.GetType().Name.Contains("Azure"))
                {
                    _path = "/_Xml_Sync_"; // TODO maybe should add TablePrefix?
                }
            }
        }
        public ReplicationManager(
            IPersister persister,
            IItemFinder finder,
            IReplicationStorage repstore,
            IFileSystemFactory fileSystemFactory,
            DatabaseSection dataBaseSection,
            ISecurityManager security,
            IIndexer indexer,    // optional
            IFlushable flushable // optional
            )
        {
            _repstore  = repstore;
            _security  = security;
            _persister = persister;
            _finder    = finder;
            _indexer   = indexer;
            _flushable = flushable;

            // detect sync direction from Database Type and double check via config
            string value = ConfigurationManager.AppSettings["XmlReplication"] ?? "false";

            IsSlave  = value.Equals("Slave", StringComparison.InvariantCultureIgnoreCase) & (dataBaseSection.Flavour == DatabaseFlavour.Xml);
            IsMaster = value.Equals("Master", StringComparison.InvariantCultureIgnoreCase) & !IsSlave;

            if (IsMaster || IsSlave)
            {
                // only initialize if replication is active
                var storageConfig = (FileSystemNamespace)Enum.Parse(typeof(FileSystemNamespace),
                                                                    ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ??
                                                                    "ReplicationStorageDebug");

                _fileSystem = fileSystemFactory.Create(storageConfig);

                // constructing these dependencies to ensure same filesystem and simplify construction
                _replicationWriteLockManager = new ReplicationWriteLockManager(_fileSystem);
                _replicationReadLockManager  = new ReplicationReadLockManager(_fileSystem);
            }
            _replicationLogPath = "/_Xml_Sync_Log";
        }
        private PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null)
        {
            project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create());
            dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create();
            IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create();

            solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create();
            IProjectLogger logger          = IProjectLoggerFactory.Create();
            IFileSystem    fileSystem      = IFileSystemFactory.Create();
            var            hintService     = new Lazy <IProjectChangeHintSubmissionService>(() => IProjectChangeHintSubmissionServiceFactory.Create());
            var            projectAccessor = IProjectAccessorFactory.Create();
            var            packageReferenceTelemetryService = IUnconfiguredProjectPackageRestoreTelemetryServiceFactory.Create();

            return(new PackageRestoreDataSource(
                       project,
                       dataSource,
                       projectAsynchronousTasksService,
                       solutionRestoreService,
                       fileSystem,
                       hintService,
                       projectAccessor,
                       logger,
                       packageReferenceTelemetryService));
        }
 public void Constructor_NullProjectTreeService_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>("projectTreeService", () =>
     {
         new SettingsFileSpecialFileProvider(null, IProjectItemProviderFactory.Create(), null, IFileSystemFactory.Create(null));
     });
 }
예제 #28
0
        public ReplicationManager(
            IPersister persister,
            IItemFinder finder,
            IReplicationStorage repstore,
            IFileSystemFactory fileSystemFactory,
            DatabaseSection dataBaseSection,
            ISecurityManager security,
            IIndexer indexer, // optional
            IFlushable flushable // optional
            )
        {
            _repstore = repstore;
            _security = security;
            _persister = persister;
            _finder = finder;
            _indexer = indexer;
            _flushable = flushable;

            // detect sync direction from Database Type and double check via config
            string value = ConfigurationManager.AppSettings["XmlReplication"] ?? "false";
            IsSlave = value.Equals("Slave", StringComparison.InvariantCultureIgnoreCase) & (dataBaseSection.Flavour == DatabaseFlavour.Xml);
            IsMaster = value.Equals("Master", StringComparison.InvariantCultureIgnoreCase) & !IsSlave;

            if (IsMaster || IsSlave)
            {
                // only initialize if replication is active
                var storageConfig = (FileSystemNamespace) Enum.Parse(typeof (FileSystemNamespace),
                               ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ??
                               "ReplicationStorageDebug");

                _fileSystem = fileSystemFactory.Create(storageConfig);

                // constructing these dependencies to ensure same filesystem and simplify construction
                _replicationWriteLockManager = new ReplicationWriteLockManager(_fileSystem);
                _replicationReadLockManager = new ReplicationReadLockManager(_fileSystem);
            }
            _replicationLogPath = "/_Xml_Sync_Log";
        }
예제 #29
0
        private static ProjectAssetsProjectEvaluationDependencyProvider CreateInstance(IFileSystem?fileSystem = null)
        {
            fileSystem ??= IFileSystemFactory.Create();

            return(new ProjectAssetsProjectEvaluationDependencyProvider(fileSystem));
        }
 public void Constructor_NullSourceItemsProvider_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>("sourceItemsProvider", () =>
     {
         new SettingsFileSpecialFileProvider(IProjectTreeServiceFactory.Create(null), null, null, IFileSystemFactory.Create(null));
     });
 }
        public void GlobaJsonSetup_NoExistingRemover_RegistersForAdvise()
        {
            UnitTestHelper.IsRunningUnitTests = true;
            GlobalJsonRemover.Remover         = null;

            var solution      = IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(1234);
            var setupOccurred = new GlobalJsonRemover.GlobalJsonSetup().SetupRemoval(solution, IServiceProviderFactory.Create(), IFileSystemFactory.Create());

            Assert.True(setupOccurred);
            Assert.Equal(1234u, GlobalJsonRemover.Remover.SolutionCookie);
        }
 public void GlobalJsonRemover_InvalidServiceProvider_Throws()
 {
     Assert.Throws <ArgumentNullException>("serviceProvider", () => new GlobalJsonRemover(null, IFileSystemFactory.Create()));
 }