diff --git a/QRCoder/Framework4.0Methods/Stream4Methods.cs b/QRCoder/Extensions/StreamExtensions.cs
similarity index 50%
rename from QRCoder/Framework4.0Methods/Stream4Methods.cs
rename to QRCoder/Extensions/StreamExtensions.cs
index 6c58eb7a..14796167 100644
--- a/QRCoder/Framework4.0Methods/Stream4Methods.cs
+++ b/QRCoder/Extensions/StreamExtensions.cs
@@ -1,13 +1,12 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace QRCoder.Framework4._0Methods
+#if NET35
+namespace QRCoder
{
- class Stream4Methods
+ internal static class StreamExtensions
{
- public static void CopyTo(System.IO.Stream input, System.IO.Stream output)
+ ///
+ /// Copies a stream to another stream.
+ ///
+ public static void CopyTo(this System.IO.Stream input, System.IO.Stream output)
{
byte[] buffer = new byte[16 * 1024];
int bytesRead;
@@ -18,3 +17,4 @@ public static void CopyTo(System.IO.Stream input, System.IO.Stream output)
}
}
}
+#endif
diff --git a/QRCoder/Extensions/StringExtensions.cs b/QRCoder/Extensions/StringExtensions.cs
new file mode 100644
index 00000000..34a44272
--- /dev/null
+++ b/QRCoder/Extensions/StringExtensions.cs
@@ -0,0 +1,27 @@
+namespace QRCoder
+{
+ internal static class StringExtensions
+ {
+ ///
+ /// Indicates whether the specified string is null, empty, or consists only of white-space characters.
+ ///
+ ///
+ /// if the is null, empty, or white space; otherwise, .
+ ///
+ public static bool IsNullOrWhiteSpace(this string value)
+ {
+#if NET35
+ if (value == null) return true;
+
+ for (int i = 0; i < value.Length; i++)
+ {
+ if (!char.IsWhiteSpace(value[i])) return false;
+ }
+
+ return true;
+#else
+ return string.IsNullOrWhiteSpace(value);
+#endif
+ }
+ }
+}
\ No newline at end of file
diff --git a/QRCoder/Framework4.0Methods/String4Methods.cs b/QRCoder/Framework4.0Methods/String4Methods.cs
deleted file mode 100644
index 748c0d69..00000000
--- a/QRCoder/Framework4.0Methods/String4Methods.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-
-namespace QRCoder
-{
- internal static class String40Methods
- {
- ///
- /// The IsNullOrWhiteSpace method from Framework4.0
- ///
- ///
- /// true if the is null or white space; otherwise, false.
- ///
- public static bool IsNullOrWhiteSpace(String value)
- {
- if (value == null) return true;
-
- for (int i = 0; i < value.Length; i++)
- {
- if (!Char.IsWhiteSpace(value[i])) return false;
- }
-
- return true;
- }
-
- public static string ReverseString(string str)
- {
- char[] chars = str.ToCharArray();
- char[] result = new char[chars.Length];
- for (int i = 0, j = str.Length - 1; i < str.Length; i++, j--)
- {
- result[i] = chars[j];
- }
- return new string(result);
- }
-
- public static bool IsAllDigit(string str)
- {
- foreach (var c in str)
- {
- if (!char.IsDigit(c))
- {
- return false;
- }
- }
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/QRCoder/PayloadGenerator.cs b/QRCoder/PayloadGenerator.cs
index bf9d22ce..bddd084b 100644
--- a/QRCoder/PayloadGenerator.cs
+++ b/QRCoder/PayloadGenerator.cs
@@ -2034,7 +2034,7 @@ private string TimeToString()
private void ProcessCommonFields(StringBuilder sb)
{
- if (String40Methods.IsNullOrWhiteSpace(Secret))
+ if (Secret.IsNullOrWhiteSpace())
{
throw new Exception("Secret must be a filled out base32 encoded string");
}
@@ -2043,7 +2043,7 @@ private void ProcessCommonFields(StringBuilder sb)
string escapedLabel = null;
string label = null;
- if (!String40Methods.IsNullOrWhiteSpace(Issuer))
+ if (!Issuer.IsNullOrWhiteSpace())
{
if (Issuer.Contains(":"))
{
@@ -2052,7 +2052,7 @@ private void ProcessCommonFields(StringBuilder sb)
escapedIssuer = Uri.EscapeDataString(Issuer);
}
- if (!String40Methods.IsNullOrWhiteSpace(Label))
+ if (!Label.IsNullOrWhiteSpace())
{
if (Label.Contains(":"))
{
diff --git a/QRCoder/QRCodeData.cs b/QRCoder/QRCodeData.cs
index e9b8a571..dbb0f06c 100644
--- a/QRCoder/QRCodeData.cs
+++ b/QRCoder/QRCodeData.cs
@@ -1,14 +1,11 @@
+using System;
using System.Collections;
using System.Collections.Generic;
-using System.Linq;
+using System.IO;
+using System.IO.Compression;
namespace QRCoder
{
- using QRCoder.Framework4._0Methods;
- using System;
- using System.IO;
- using System.IO.Compression;
-
public class QRCodeData : IDisposable
{
public List ModuleMatrix { get; set; }
@@ -48,7 +45,7 @@ public QRCodeData(byte[] rawData, Compression compressMode)
{
using (var dstream = new DeflateStream(input, CompressionMode.Decompress))
{
- Stream4Methods.CopyTo(dstream, output);
+ dstream.CopyTo(output);
}
bytes = new List(output.ToArray());
}
@@ -62,7 +59,7 @@ public QRCodeData(byte[] rawData, Compression compressMode)
{
using (var dstream = new GZipStream(input, CompressionMode.Decompress))
{
- Stream4Methods.CopyTo(dstream, output);
+ dstream.CopyTo(output);
}
bytes = new List(output.ToArray());
}