Ejemplo n.º 1
0
        public FileSystemFileReference(
            string filePath,
            string path,
            FileSystemStore store,
            bool withMetadata,
            FileExtendedProperties extendedProperties,
            IPublicUrlProvider publicUrlProvider,
            IExtendedPropertiesProvider extendedPropertiesProvider)
        {
            this.FileSystemPath             = filePath;
            this.Path                       = path.Replace('\\', '/');
            this.store                      = store;
            this.extendedPropertiesProvider = extendedPropertiesProvider;
            this.withMetadata               = withMetadata;

            this.propertiesLazy = new Lazy <IFileProperties>(() =>
            {
                if (withMetadata)
                {
                    return(new FileSystemFileProperties(this.FileSystemPath, extendedProperties));
                }

                throw new InvalidOperationException("Metadata are not loaded, please use withMetadata option");
            });

            this.publicUrlLazy = new Lazy <string>(() =>
            {
                if (publicUrlProvider != null)
                {
                    return(publicUrlProvider.GetPublicUrl(this.store.Name, this));
                }

                throw new InvalidOperationException("There is not FileSystemServer enabled.");
            });
        }
Ejemplo n.º 2
0
        private async ValueTask<Internal.FileSystemFileReference> InternalGetAsync(string path, bool withMetadata, bool checkIfExists = true)
        {
            var fullPath = Path.Combine(this.AbsolutePath, path);
            if (checkIfExists && !File.Exists(fullPath))
            {
                return null;
            }

            Internal.FileExtendedProperties extendedProperties = null;
            if (withMetadata)
            {
                if (this.extendedPropertiesProvider == null)
                {
                    throw new InvalidOperationException("There is no FileSystem extended properties provider.");
                }

                extendedProperties = await this.extendedPropertiesProvider.GetExtendedPropertiesAsync(
                    this.AbsolutePath,
                    new Storage.Internal.PrivateFileReference(path));
            }

            return new Internal.FileSystemFileReference(
                fullPath,
                path,
                this,
                withMetadata,
                extendedProperties,
                this.publicUrlProvider,
                this.extendedPropertiesProvider);
        }
Ejemplo n.º 3
0
 public FileSystemFileProperties(string fileSystemPath, FileExtendedProperties extendedProperties)
 {
     this.fileInfo           = new FileInfo(fileSystemPath);
     this.extendedProperties = extendedProperties;
 }