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