Advertisement
Guest User

Untitled

a guest
Sep 13th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1.     public abstract class BaseInputLog : IDisposable
  2.     {
  3.         protected System.IO.StreamReader file;
  4.      
  5.         public BaseInputLog()
  6.         {
  7.             this.LoadFile();
  8.         }
  9.  
  10.         protected abstract void LoadFile();
  11.  
  12.         public string ReadLine()
  13.         {
  14.             return this.file.ReadLine();
  15.         }
  16.  
  17.         public int Peek()
  18.         {
  19.             return this.file.Peek();
  20.         }
  21.  
  22.         public void Close()
  23.         {
  24.             this.file.Close();
  25.         }
  26.  
  27.         public void Dispose()
  28.         {
  29.             this.file.Dispose();
  30.         }
  31.     }
  32.  
  33.     public class InputLogFileSystem : BaseInputLog
  34.     {
  35.         private readonly string filePath;
  36.         public InputLogFileSystem(string path) : base()
  37.         {
  38.             this.filePath = path;
  39.         }
  40.  
  41.         protected override void LoadFile()
  42.         {
  43.             this.file = new System.IO.StreamReader(this.filePath);
  44.         }
  45.     }
  46.  
  47.     public class InputLogFTP : BaseInputLog
  48.     {
  49.  
  50.         private readonly string uri;
  51.         private readonly string user;
  52.         private readonly int port;
  53.         private readonly string password;
  54.         public InputLogFTP(string uri) : base()
  55.         {
  56.             this.uri      = uri;
  57.             this.user     = string.Empty;
  58.             this.port     = 22;
  59.             this.password = string.Empty;
  60.         }
  61.  
  62.         public InputLogFTP(string uri, int port, string user, string password) : base()
  63.         {
  64.             this.uri = uri;
  65.             this.user = user;
  66.             this.port = port;
  67.             this.password = password;
  68.         }
  69.  
  70.         protected override void LoadFile()
  71.         {
  72.             string localFilePath = string.Empty;
  73.             //localFilePath = downloaded from ftp
  74.             this.file = new System.IO.StreamReader(localFilePath);
  75.         }
  76.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement