Exemplo n.º 1
0
        public static IConfigurationBuilder AddImageFile(this IConfigurationBuilder builder, IFileProvider provider, string imagePath, string regionsPath, bool optional, bool reloadOnChange)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (string.IsNullOrEmpty(imagePath))
            {
                throw new ArgumentException("Invalid file path.", nameof(imagePath));
            }
            if (string.IsNullOrEmpty(regionsPath))
            {
                throw new ArgumentException("Invalid regions path.", nameof(regionsPath));
            }
            if (provider == null)
            {
                if (Path.IsPathRooted(imagePath))
                {
                    provider  = new PhysicalFileProvider(Path.GetDirectoryName(imagePath));
                    imagePath = Path.GetFileName(imagePath);
                }
                if (Path.IsPathRooted(regionsPath))
                {
                    provider    = new PhysicalFileProvider(Path.GetDirectoryName(imagePath));
                    regionsPath = Path.GetFileName(regionsPath);
                }
            }
            var source = new ImageConfigurationSource
            {
                FileProvider   = provider,
                Path           = imagePath,
                RegionsPath    = regionsPath,
                Optional       = optional,
                ReloadOnChange = reloadOnChange
            };

            builder.Add(source);
            return(builder);
        }
Exemplo n.º 2
0
 public ImageConfigurationProvider(ImageConfigurationSource source) : base(source)
 {
 }