TextReader.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // System.IO.TextWriter
  3. //
  4. // Author: Marcin Szczepanski ([email protected])
  5. //
  6. // TODO: Implement the Thread Safe stuff
  7. //
  8. using System;
  9. namespace System.IO {
  10. public abstract class TextReader : MarshalByRefObject, IDisposable {
  11. protected TextReader() { }
  12. public static readonly TextReader Null;
  13. public virtual void Close()
  14. {
  15. Dispose(true);
  16. }
  17. void System.IDisposable.Dispose()
  18. {
  19. Dispose(true);
  20. }
  21. protected virtual void Dispose( bool disposing )
  22. {
  23. return;
  24. }
  25. public virtual int Peek()
  26. {
  27. return -1;
  28. }
  29. public virtual int Read()
  30. {
  31. return -1;
  32. }
  33. // LAMESPEC: The Beta2 docs say this should be Read( out char[] ...
  34. // whereas the MS implementation is just Read( char[] ... )
  35. // Not sure which one is right, we'll see in Beta3 :)
  36. public virtual int Read (char[] buffer, int index, int count)
  37. {
  38. int c, i;
  39. for (i = 0; i < count; i++) {
  40. if ((c = Read ()) == -1)
  41. return i;
  42. buffer [index + i] = (char)c;
  43. }
  44. return i;
  45. }
  46. public virtual int ReadBlock( char[] buffer, int index, int count )
  47. {
  48. return 0;
  49. }
  50. public virtual string ReadLine()
  51. {
  52. return String.Empty;
  53. }
  54. public virtual string ReadToEnd()
  55. {
  56. return String.Empty;
  57. }
  58. public static TextReader Synchronised( TextReader reader )
  59. {
  60. // TODO: Implement
  61. return Null;
  62. }
  63. }
  64. }