diff options
Diffstat (limited to 'source/Janrain.OpenId/Consumer/Util.cs')
-rw-r--r-- | source/Janrain.OpenId/Consumer/Util.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/Janrain.OpenId/Consumer/Util.cs b/source/Janrain.OpenId/Consumer/Util.cs new file mode 100644 index 0000000..d1fa94e --- /dev/null +++ b/source/Janrain.OpenId/Consumer/Util.cs @@ -0,0 +1,41 @@ +using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+
+namespace Janrain.OpenId.Consumer
+{
+ public class Util
+ {
+ public static byte[] ReadAndClose(Stream stream)
+ {
+ StreamReader sr = new StreamReader(stream, Encoding.UTF8);
+ List<byte> bytes = new List<byte>();
+ int byteValue = 0;
+ bool keepReading = true;
+ while (keepReading)
+ {
+ try
+ {
+ byteValue = sr.Read();
+ if (byteValue == -1)
+ {
+ keepReading = false;
+ }
+ else
+ {
+ bytes.Add(Convert.ToByte(byteValue));
+ }
+
+ }
+ catch (Exception)
+ {
+ keepReading = false;
+ }
+ }
+ stream.Close();
+ byte[] allbytes = bytes.ToArray();
+ return allbytes;
+ }
+ }
+}
|