-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished FileReader mechanism. Added Open file functionality
- Loading branch information
1 parent
bf92706
commit e78f565
Showing
7 changed files
with
106 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TextEditor.FileManager | ||
{ | ||
/// <summary> | ||
/// Provides algorithm to reading ASCII encoded file. | ||
/// </summary> | ||
public class DefaultFileReader : FileReaderStrategy | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DefaultFileReader"/> class. | ||
/// </summary> | ||
/// <param name="fileName">Path to read file.</param> | ||
public DefaultFileReader(string fileName) | ||
{ | ||
this.FileName = fileName; | ||
} | ||
|
||
/// <summary> | ||
/// Reads data from file. | ||
/// </summary> | ||
/// <returns>Array of read strings.</returns> | ||
public override string[] Read() | ||
{ | ||
List<string> result = new List<string>(); | ||
using (System.IO.StreamReader streamReader = new System.IO.StreamReader(this.FileName)) | ||
{ | ||
while (!streamReader.EndOfStream) | ||
{ | ||
result.Add(streamReader.ReadLine()); | ||
} | ||
} | ||
|
||
return result.ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters