Пример #1
0
        public IManifestInfo GetManifest(string subPath)
        {
            IConfigurationBuilder configurationBuilder
                = new ConfigurationBuilder();

            string type = null;

            foreach (var manifestConfiguration in _manifestOptions.ManifestConfigurations)
            {
                var filePath = Path.Combine(subPath, manifestConfiguration.ManifestFileName);

                if (_fileProvider.GetFileInfo(filePath).Exists)
                {
                    configurationBuilder =
                        _manifestProvider.GetManifestConfiguration(
                            configurationBuilder,
                            filePath
                            );

                    type = manifestConfiguration.Type;
                }
            }

            if (type == null || !configurationBuilder.Sources.Any())
            {
                return(new NotFoundManifestInfo(subPath));
            }

            var config = configurationBuilder.Build();

            return(new ManifestInfo(config, type));
        }
Пример #2
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);
        }