示例#1
0
        public string NormalizeFileName(FileContainerConfiguration configuration, string fileName)
        {
            if (!configuration.NamingNormalizers.Any())
            {
                return(fileName);
            }

            return(NormalizeNaming(configuration, null, fileName).FileName);
        }
示例#2
0
        public string NormalizeContainerName(FileContainerConfiguration configuration, string containerName)
        {
            if (!configuration.NamingNormalizers.Any())
            {
                return(containerName);
            }

            return(NormalizeNaming(configuration, containerName, null).ContainerName);
        }
 protected FileProviderArgs(
     [NotNull] string containerName,
     [NotNull] FileContainerConfiguration configuration,
     [CanBeNull] string fileId,
     CancellationToken cancellationToken = default)
 {
     ContainerName     = Check.NotNullOrWhiteSpace(containerName, nameof(containerName));
     Configuration     = Check.NotNull(configuration, nameof(configuration));
     FileId            = fileId;
     CancellationToken = cancellationToken;
 }
 public FileProviderExistsArgs(
     [NotNull] string containerName,
     [NotNull] FileContainerConfiguration configuration,
     [NotNull] string fileId,
     CancellationToken cancellationToken = default)
     : base(
         containerName,
         configuration,
         fileId,
         cancellationToken)
 {
 }
 public FileProviderSaveArgs(
     [NotNull] string containerName,
     [NotNull] FileContainerConfiguration configuration,
     [CanBeNull] string fileId,
     [NotNull] Stream fileStream,
     [NotNull] string fileExt,
     bool overrideExisting = false,
     CancellationToken cancellationToken = default)
     : this(containerName, configuration, fileId, overrideExisting, cancellationToken)
 {
     FileStream = Check.NotNull(fileStream, nameof(fileStream));
     FileExt    = Check.NotNullOrWhiteSpace(fileExt, nameof(fileExt));
 }
示例#6
0
        public static object GetConfiguration(
            [NotNull] this FileContainerConfiguration containerConfiguration,
            [NotNull] string name)
        {
            var value = containerConfiguration.GetConfigurationOrNull(name);

            if (value == null)
            {
                throw new AbpException($"Could not find the configuration value for '{name}'!");
            }

            return(value);
        }
 public FileProviderSaveArgs(
     [NotNull] string containerName,
     [NotNull] FileContainerConfiguration configuration,
     [CanBeNull] string fileId,
     bool overrideExisting = false,
     CancellationToken cancellationToken = default)
     : base(
         containerName,
         configuration,
         fileId,
         cancellationToken)
 {
     OverrideExisting = overrideExisting;
 }
示例#8
0
 public FileProviderAccessArgs(
     [NotNull] string containerName,
     [NotNull] FileContainerConfiguration configuration,
     [NotNull] string fileId,
     [CanBeNull] DateTime?expires        = null,
     CancellationToken cancellationToken = default)
     : base(
         containerName,
         configuration,
         fileId,
         cancellationToken)
 {
     Expires = expires;
 }
示例#9
0
 public FileProviderDownloadArgs(
     [NotNull] string containerName,
     [NotNull] FileContainerConfiguration configuration,
     [NotNull] string fileId,
     [NotNull] string path,
     CancellationToken cancellationToken = default)
     : base(
         containerName,
         configuration,
         fileId,
         cancellationToken)
 {
     Path = path;
 }
示例#10
0
        public virtual FileNormalizeNaming NormalizeNaming(
            FileContainerConfiguration configuration,
            string containerName,
            string fileName)
        {
            if (!configuration.NamingNormalizers.Any())
            {
                return(new FileNormalizeNaming(containerName, fileName));
            }

            using var scope = ServiceProvider.CreateScope();
            foreach (var normalizerType in configuration.NamingNormalizers)
            {
                var normalizer = scope.ServiceProvider
                                 .GetRequiredService(normalizerType)
                                 .As <IFileNamingNormalizer>();

                containerName = containerName.IsNullOrWhiteSpace() ? containerName : normalizer.NormalizeContainerName(containerName);
                fileName      = fileName.IsNullOrWhiteSpace() ? fileName : normalizer.NormalizeFileName(fileName);
            }

            return(new FileNormalizeNaming(containerName, fileName));
        }
 public FileContainerConfiguration(FileContainerConfiguration fallbackConfiguration = null)
 {
     NamingNormalizers      = new TypeList <IFileNamingNormalizer>();
     _fallbackConfiguration = fallbackConfiguration;
     _properties            = new Dictionary <string, object>();
 }
示例#12
0
 public static T GetConfiguration <T>(
     [NotNull] this FileContainerConfiguration containerConfiguration,
     [NotNull] string name)
 {
     return((T)containerConfiguration.GetConfiguration(name));
 }