Пример #1
0
        private static bool DoesHostSupportRoslynAnalzyers(IComponentContainer container)
        {
            bool hostSupportsRoslynAnalzyers = false;

            // There's probably a nicer way of optionally testing for this, but this works for now
            var vsEnvironmentInformation = container.TryGetComponent <IVsEnvironmentInformation>();

            if (vsEnvironmentInformation != null)
            {
                hostSupportsRoslynAnalzyers = vsEnvironmentInformation.VsVersion2 >= new Version2(14);
            }

            return(hostSupportsRoslynAnalzyers);
        }
Пример #2
0
        public ConfigurationSenseOptionsPage(
            [NotNull] Lifetime lifetime,
            [NotNull] OptionsSettingsSmartContext optionsSettingsSmartContext,
            IComponentContainer componentContainer,
            ProjectModelElementPresentationService presentationService,
            IUIApplication iuiApplication)
            : base(lifetime, optionsSettingsSmartContext)
        {
            var solution = componentContainer.TryGetComponent <ISolution>();

            if (solution == null)
            {
                AddHeader("To edit the list of additional configuration files you should open a solution.");
                return;
            }

            var editItemViewModelFactory = new FilesAndDirsCollectionEditItemViewModelFactory(iuiApplication.ShellLocks, presentationService);
            var buttonProviderFactory    = new FilesAndDirsButtonProviderFactory(
                lifetime,
                iuiApplication.ShellLocks,
                solution,
                editItemViewModelFactory,
                false);

            var customConfigurationFiles = new StringCollectionEditViewModel(
                lifetime,
                @"Additional configuration files. 
You don't need to add appsettings.json, web.config and app.config to the list, they're scanned by default. 
Only *.json and *.xml files are supported.",
                buttonProviderFactory,
                editItemViewModelFactory);

            using (ReadLockCookie.Create())
            {
                foreach (var x in optionsSettingsSmartContext.GetAdditionalConfigurationFiles(solution.GetId()))
                {
                    var element = solution.FindElementByPersistentID(x);
                    if (element == null)
                    {
                        continue;
                    }

                    customConfigurationFiles.AddItem(element.Name, behindValue: element);
                }
            }

            customConfigurationFiles.Items.CollectionChanged += (o, e) =>
            {
                var hashSet = new HashSet <string>();
                foreach (var item in customConfigurationFiles.Items)
                {
                    var filesAndDirsItem = (FilesAndDirsItemViewModel)item;
                    if (filesAndDirsItem.ProjectElement is IProjectFile projectFile &&
                        (projectFile.LanguageType.Is <JsonProjectFileType>() ||
                         projectFile.LanguageType.Is <XmlProjectFileType>()))
                    {
                        hashSet.Add(projectFile.GetPersistentID());
                    }
                }

                OptionsSettingsSmartContext.SaveCustomConfigurationFiles(solution.GetId(), hashSet);
            };

            AddHeader("Configuration files");
            AddCustomOption(customConfigurationFiles);
        }