Guest User

Untitled

a guest
Jul 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. FileClass
  2.  
  3. GetContentFromFile(string path).
  4.  
  5. File.exists(string path)
  6.  
  7. public class FileClass
  8. {
  9. public string GetContentFromFile(string path)
  10. {
  11. if (File.exists(path))
  12. {
  13. //Do some more logic in here...
  14. }
  15. }
  16. }
  17.  
  18. public interface IFileWrapper {
  19. bool Exists(string path);
  20. }
  21.  
  22. public class FileWrapper : IFileWrapper {
  23. public bool Exists(string path) {
  24. return File.Exists(path);
  25. }
  26. }
  27.  
  28. public class FileClass {
  29. private readonly IFileWrapper wrapper;
  30.  
  31. public FileClass(IFileWrapper wrapper) {
  32. this.wrapper = wrapper;
  33. }
  34.  
  35. public string GetContentFromFile(string path){
  36. if (wrapper.FileExists(path)) {
  37. //Do some more logic in here...
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment