コード例 #1
0
        public void ThatGetExtensionInfoShouldReturnExtensionWhenManifestIsPresent()
        {
            var extension = Provider.GetExtensionInfo("Sample1");

            Assert.Equal("Sample1", extension.Id);
            Assert.True(extension.ExtensionFileInfo.Exists);
        }
コード例 #2
0
        public IEnumerable <IExtensionInfo> GetExtensions()
        {
            if (_extensionsById == null)
            {
                var extensionsById = new Dictionary <string, IExtensionInfo>();

                foreach (var searchPath in _extensionOptions.SearchPaths)
                {
                    foreach (var subDirectory in _hostingEnvironment
                             .ContentRootFileProvider
                             .GetDirectoryContents(searchPath)
                             .Where(x => x.IsDirectory))
                    {
                        var extensionId = subDirectory.Name;

                        if (!extensionsById.ContainsKey(extensionId))
                        {
                            var subPath = Path.Combine(searchPath, extensionId);

                            var extensionInfo =
                                _extensionProvider.GetExtensionInfo(subPath);

                            if (extensionInfo.ExtensionFileInfo.Exists)
                            {
                                extensionsById.Add(extensionId, extensionInfo);
                            }
                        }
                    }
                }

                _extensionsById = extensionsById;
            }

            return(_extensionsById.Values);
        }
コード例 #3
0
        private ISet <IExtensionInfo> HarvestExtensions()
        {
            var searchOptions = _extensionExpanderOptions.Options;

            var extensionSet = new HashSet <IExtensionInfo>();

            if (searchOptions.Count == 0)
            {
                return(extensionSet);
            }

            foreach (var searchOption in searchOptions)
            {
                foreach (var subDirectory in _hostingEnvironment
                         .ContentRootFileProvider
                         .GetDirectoryContents(searchOption.SearchPath)
                         .Where(x => x.IsDirectory))
                {
                    var manifestConfiguration = _manifestOptions
                                                .ManifestConfigurations
                                                .FirstOrDefault(mc =>
                    {
                        return(File.Exists(Path.Combine(subDirectory.PhysicalPath, mc.ManifestFileName)));
                    }
                                                                );

                    if (manifestConfiguration == null)
                    {
                        continue;
                    }

                    var manifestsubPath     = Path.Combine(searchOption.SearchPath, subDirectory.Name);
                    var manifestFilesubPath = Path.Combine(manifestsubPath, manifestConfiguration.ManifestFileName);

                    IConfigurationBuilder configurationBuilder =
                        _manifestProvider.GetManifestConfiguration(new ConfigurationBuilder(), manifestFilesubPath);

                    if (!configurationBuilder.Sources.Any())
                    {
                        continue;
                    }

                    var configurationRoot = configurationBuilder.Build();

                    var manifestInfo = new ManifestInfo(configurationRoot, manifestConfiguration.Type);

                    // Manifest tells you what your loading, subpath is where you are loading it
                    var extensionInfo = _extensionProvider
                                        .GetExtensionInfo(manifestInfo, manifestsubPath);

                    extensionSet.Add(extensionInfo);
                }
            }

            return(extensionSet);
        }