PageRenderTime 66ms CodeModel.GetById 58ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/DotNetSlave.BusinessLogic/Providers/FileSystemProviders/BlogFileSystemProvider.cs

#
C# | 143 lines | 28 code | 19 blank | 96 comment | 0 complexity | 6d7fab22e046aca67c7a7a823eaec657 MD5 | raw file
  1using System.Collections.Generic;
  2using System.Configuration.Provider;
  3using BlogEngine.Core.FileSystem;
  4
  5namespace BlogEngine.Core.Providers
  6{
  7    public abstract class BlogFileSystemProvider : ProviderBase
  8    {
  9        #region FileSystem
 10
 11        /// <summary>
 12        /// Clears a file system. This will delete all files and folders recursivly.
 13        /// </summary>
 14        /// <remarks>
 15        /// Handle with care... Possibly an internal method?
 16        /// </remarks>
 17        public abstract void ClearFileSystem();
 18
 19        /// <summary>
 20        /// Creates a directory at a specific path
 21        /// </summary>
 22        /// <param name="VirtualPath">The virtual path to be created</param>
 23        /// <returns>the new Directory object created</returns>
 24        /// <remarks>
 25        /// Virtual path is the path starting from the /files/ containers
 26        /// The entity is created against the current blog id
 27        /// </remarks>
 28        internal abstract Directory CreateDirectory(string VirtualPath);
 29
 30        /// <summary>
 31        /// Deletes a spefic directory from a virtual path
 32        /// </summary>
 33        /// <param name="VirtualPath">The path to delete</param>
 34        /// <remarks>
 35        /// Virtual path is the path starting from the /files/ containers
 36        /// The entity is queried against to current blog id
 37        /// </remarks>
 38        public abstract void DeleteDirectory(string VirtualPath);
 39
 40        /// <summary>
 41        /// Returns wether or not the specific directory by virtual path exists
 42        /// </summary>
 43        /// <param name="VirtualPath">The virtual path to query</param>
 44        /// <returns>boolean</returns>
 45        public abstract bool DirectoryExists(string VirtualPath);
 46
 47        /// <summary>
 48        /// gets a directory by the virtual path, creates the directory path if it does not exist
 49        /// </summary>
 50        /// <param name="VirtualPath">the virtual path</param>
 51        /// <returns>the directory object</returns>
 52        public abstract Directory GetDirectory(string VirtualPath);
 53
 54        /// <summary>
 55        /// gets a directory by the virtual path, with a flag to create if not found
 56        /// </summary>
 57        /// <param name="VirtualPath">The virtual path</param>
 58        /// <param name="CreateNew">bool yes \ no to create the director.</param>
 59        /// <returns>the directory object, or null if the create flag is set to false</returns>
 60        public abstract Directory GetDirectory(string VirtualPath, bool CreateNew);
 61
 62        /// <summary>
 63        /// gets a directory by a basedirectory and a string array of sub path tree, directory will be created if not found
 64        /// </summary>
 65        /// <param name="BaseDirectory">the base directory object</param>
 66        /// <param name="SubPath">the params of sub path</param>
 67        /// <returns>the directory found</returns>
 68        public abstract Directory GetDirectory(Directory BaseDirectory, params string[] SubPath);
 69
 70        /// <summary>
 71        /// gets a directory by a basedirectory and a string array of sub path tree
 72        /// </summary>
 73        /// <param name="BaseDirectory">the base directory object</param>
 74        /// <param name="CreateNew">if set will create the directory structure</param>
 75        /// <param name="SubPath">the params of sub path</param>
 76        /// <returns>the directory found, or null for no directory found</returns>
 77        public abstract Directory GetDirectory(Directory BaseDirectory, bool CreateNew, params string[] SubPath);
 78
 79        /// <summary>
 80        /// gets all the directories underneath a base directory. Only searches one level.
 81        /// </summary>
 82        /// <param name="BaseDirectory">the base directory</param>
 83        /// <returns>collection of Directory objects</returns>
 84        public abstract IEnumerable<Directory> GetDirectories(Directory BaseDirectory);
 85
 86        /// <summary>
 87        /// gets all the files in a directory, only searches one level
 88        /// </summary>
 89        /// <param name="BaseDirectory">the base directory</param>
 90        /// <returns>collection of File objects</returns>
 91        public abstract IEnumerable<File> GetFiles(Directory BaseDirectory);
 92
 93        /// <summary>
 94        /// gets a specific file by virtual path
 95        /// </summary>
 96        /// <param name="VirtualPath">the virtual path of the file</param>
 97        /// <returns></returns>
 98        public abstract File GetFile(string VirtualPath);
 99
100        /// <summary>
101        /// boolean wether a file exists by its virtual path
102        /// </summary>
103        /// <param name="VirtualPath">the virtual path</param>
104        /// <returns>boolean</returns>
105        public abstract bool FileExists(string VirtualPath);
106
107        /// <summary>
108        /// deletes a file by virtual path
109        /// </summary>
110        /// <param name="VirtualPath">virtual path</param>
111        public abstract void DeleteFile(string VirtualPath);
112
113        /// <summary>
114        /// uploads a file to the provider container
115        /// </summary>
116        /// <param name="FileBinary">file contents as byte array</param>
117        /// <param name="FileName">the file name</param>
118        /// <param name="BaseDirectory">directory object that is the owner</param>
119        /// <returns>the new file object</returns>
120        public abstract File UploadFile(byte[] FileBinary, string FileName, Directory BaseDirectory);
121
122        /// <summary>
123        /// uploads a file to the provider container
124        /// </summary>
125        /// <param name="FileBinary">the contents of the file as a byte array</param>
126        /// <param name="FileName">the file name</param>
127        /// <param name="BaseDirectory">the directory object that is the owner</param>
128        /// <param name="Overwrite">boolean wether to overwrite the file if it exists.</param>
129        /// <returns>the new file object</returns>
130        public abstract File UploadFile(byte[] FileBinary, string FileName, Directory BaseDirectory, bool Overwrite);
131
132        /// <summary>
133        /// gets the file contents via Lazy load, however in the DbProvider the Contents are loaded when the initial object is created to cut down on DbReads
134        /// </summary>
135        /// <param name="BaseFile">the baseFile object to fill</param>
136        /// <returns>the original file object</returns>
137        internal abstract File GetFileContents(File BaseFile);
138
139
140        public abstract Image ImageThumbnail(string VirtualPath, int MaximumSize);
141        #endregion
142    }
143}