Last active
December 30, 2016 15:57
-
-
Save KallDrexx/21cbdab26f952a78d48d1938f41717f2 to your computer and use it in GitHub Desktop.
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
public interface IStringReader | |
{ | |
IEnumerable<string> GetStrings(); | |
} | |
public class InMemoryStringReader : IStringReader | |
{ | |
private readonly string[] _strings; | |
public InMemoryStringReader(string[] strings) | |
{ | |
_strings = strings; | |
} | |
public IEnumerable<string> GetStrings() | |
{ | |
return _strings; | |
} | |
} | |
public class NetworkStringReader : IStringReader | |
{ | |
private readonly TcpClient _client; | |
private readonly StreamReader _reader; | |
public NetworkStringReader(TcpClient client) | |
{ | |
_client = client; | |
_reader = new StreamReader(client.GetStream()); | |
} | |
public IEnumerable<string> GetStrings() | |
{ | |
yield return _reader.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment