Example #1
0
        private void RegisterLocalServices()
        {
            this.localServices.Add(typeof(ISolutionRuleSetsInformationProvider), new Lazy <ILocalService>(() => new SolutionRuleSetsInformationProvider(this, Logger)));
            this.localServices.Add(typeof(IRuleSetSerializer), new Lazy <ILocalService>(() => new RuleSetSerializer()));
            this.localServices.Add(typeof(ICredentialStoreService), new Lazy <ILocalService>(() => new CredentialStore(new SecretStore("SonarLint.VisualStudio.Integration"))));
            this.localServices.Add(typeof(IConfigurationProvider), new Lazy <ILocalService>(() =>
            {
                var solution = this.GetService <SVsSolution, IVsSolution>();
                var connectedModeConfigPathProvider = new ConnectedModeSolutionBindingPathProvider(solution);
                var legacyConfigPathProvider        = new LegacySolutionBindingPathProvider(this);
                var legacyPostSaveOperation         = new LegacySolutionBindingPostSaveOperation(this);

                var store             = this.GetService <ICredentialStoreService>();
                var credentialsLoader = new SolutionBindingCredentialsLoader(store);
                var bindingFileLoader = new SolutionBindingFileLoader(Logger);

                var sccFileSystem = this.GetService <ISourceControlledFileSystem>();

                var bindingSerializer = new SolutionBindingSerializer(sccFileSystem, bindingFileLoader, credentialsLoader);

                return(new ConfigurationProvider(legacyConfigPathProvider, connectedModeConfigPathProvider, bindingSerializer, legacyPostSaveOperation));
            }));

            var projectNameTestProjectIndicator = new Lazy <ILocalService>(() => new ProjectNameTestProjectIndicator(Logger));

            this.localServices.Add(typeof(ITestProjectRegexSetter), projectNameTestProjectIndicator);

            this.localServices.Add(typeof(IProjectSystemHelper), new Lazy <ILocalService>(() => new ProjectSystemHelper(this)));
            this.localServices.Add(typeof(IRuleSetInspector), new Lazy <ILocalService>(() => new RuleSetInspector(this, Logger)));
            this.localServices.Add(typeof(IRuleSetConflictsController), new Lazy <ILocalService>(() => new RuleSetConflictsController(this, new ConflictsManager(this, Logger))));
            this.localServices.Add(typeof(IProjectSystemFilter), new Lazy <ILocalService>(() =>
            {
                var testProjectIndicators = new List <ITestProjectIndicator>
                {
                    new BuildPropertyTestProjectIndicator(this),
                    new ProjectKindTestProjectIndicator(this),
                    new ProjectCapabilityTestProjectIndicator(this),
                    new ServiceGuidTestProjectIndicator(Logger),
                    projectNameTestProjectIndicator.Value as ITestProjectIndicator,
                };

                var testProjectIndicator = new TestProjectIndicator(testProjectIndicators);

                return(new ProjectSystemFilter(this, testProjectIndicator));
            }));
            this.localServices.Add(typeof(IErrorListInfoBarController), new Lazy <ILocalService>(() => new ErrorListInfoBarController(this, new UnboundProjectFinder(this))));

            // Use Lazy<object> to avoid creating instances needlessly, since the interfaces are serviced by the same instance
            var sccFs = new Lazy <ILocalService>(() => new SourceControlledFileSystem(this, Logger));

            this.localServices.Add(typeof(ISourceControlledFileSystem), sccFs);

            Debug.Assert(SupportedLocalServices.Length == this.localServices.Count, "Unexpected number of local services");
            Debug.Assert(SupportedLocalServices.All(t => this.localServices.ContainsKey(t)), "Not all the LocalServices are registered");
        }
        private void RegisterLocalServices()
        {
            this.localServices.Add(typeof(ISolutionRuleSetsInformationProvider), new Lazy <ILocalService>(() => new SolutionRuleSetsInformationProvider(this, Logger)));
            this.localServices.Add(typeof(IRuleSetSerializer), new Lazy <ILocalService>(() => new RuleSetSerializer()));
            this.localServices.Add(typeof(ICredentialStoreService), new Lazy <ILocalService>(() => credentialStoreService));

            this.localServices.Add(typeof(IConfigurationProviderService), new Lazy <ILocalService>(() => new ConfigurationProvider(this, credentialStoreService, Logger)));
            this.localServices.Add(typeof(IConfigurationPersister), new Lazy <ILocalService>(GetConfigurationPersister));

            var projectNameTestProjectIndicator = new Lazy <ILocalService>(() => new ProjectNameTestProjectIndicator(Logger));

            this.localServices.Add(typeof(ITestProjectRegexSetter), projectNameTestProjectIndicator);

            this.localServices.Add(typeof(IProjectSystemHelper), new Lazy <ILocalService>(() => new ProjectSystemHelper(this)));
            this.localServices.Add(typeof(IRuleSetInspector), new Lazy <ILocalService>(() => new RuleSetInspector(this, Logger)));
            this.localServices.Add(typeof(IRuleSetConflictsController), new Lazy <ILocalService>(() => new RuleSetConflictsController(this, new ConflictsManager(this, Logger))));
            this.localServices.Add(typeof(IProjectSystemFilter), new Lazy <ILocalService>(() =>
            {
                var testProjectIndicators = new List <ITestProjectIndicator>
                {
                    new BuildPropertyTestProjectIndicator(this),
                    new ProjectKindTestProjectIndicator(this),
                    new ProjectCapabilityTestProjectIndicator(this),
                    new ServiceGuidTestProjectIndicator(Logger),
                    projectNameTestProjectIndicator.Value as ITestProjectIndicator,
                };

                var testProjectIndicator = new TestProjectIndicator(testProjectIndicators);

                return(new ProjectSystemFilter(this, testProjectIndicator));
            }));
            this.localServices.Add(typeof(IErrorListInfoBarController), new Lazy <ILocalService>(() => new ErrorListInfoBarController(this, new UnboundProjectFinder(this, Logger))));

            // Use Lazy<object> to avoid creating instances needlessly, since the interfaces are serviced by the same instance
            var sccFs = new Lazy <ILocalService>(() => new SourceControlledFileSystem(this, Logger));

            this.localServices.Add(typeof(ISourceControlledFileSystem), sccFs);

            Debug.Assert(SupportedLocalServices.Length == this.localServices.Count, "Unexpected number of local services");
            Debug.Assert(SupportedLocalServices.All(t => this.localServices.ContainsKey(t)), "Not all the LocalServices are registered");
        }