예제 #1
0
        public virtual IFileProvider Get([NotNull] string containerName)
        {
            Check.NotNull(containerName, nameof(containerName));
            var configuration = ConfigurationProvider.Get(containerName);

            if (!FileProviders.Any())
            {
                throw new AbpException("No FILE Storage provider was registered! At least one provider must be registered to be able to use the Blog Storing System.");
            }

            foreach (var provider in FileProviders)
            {
                if (provider.Provider.Equals(configuration.Provider, StringComparison.OrdinalIgnoreCase))
                {
                    return(provider);
                }
                //if (ProxyHelper.GetUnProxiedType(provider).IsAssignableTo(configuration.Provider))
                //{
                //    return provider;
                //}
            }

            throw new AbpException(
                      $"Could not find the FILE Storage provider with the type ({configuration.Provider}) configured for the container {containerName} and no default provider was set."
                      );
        }
예제 #2
0
        public static LocalFileProvider AddLocalProvider(params string[] directories)
        {
            var provider = new LocalFileProvider();

            foreach (var dir in directories)
            {
                provider.AddFileDirectory(dir);
            }
            FileProviders.Add(provider);
            return(provider);
        }
예제 #3
0
        public static void Init()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            FileProviders.Add(new WorkshopFileProvider());
            AddLocalProvider(Structure.RuntimePath);
            Build();
        }
예제 #4
0
        public IFileProvider GetFileProvider(NormalizedPath path)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (path.IsRelative)
            {
                throw new ArgumentException("The path must be absolute");
            }
            IFileProvider fileProvider;

            if (!FileProviders.TryGet(path.Provider, out fileProvider))
            {
                throw new KeyNotFoundException($"Provider {path.Provider} could not be found");
            }
            return(fileProvider);
        }