summary refs log tree commit diff
path: root/crypto/src/util/Platform.cs
diff options
context:
space:
mode:
authorOren Novotny <oren@novotny.org>2015-11-22 12:52:48 -0500
committerOren Novotny <oren@novotny.org>2015-11-22 12:52:48 -0500
commitc2bc6d18b888c0a3d3d1177e7c049f042dcae3ac (patch)
tree5d2da28f9361f54df868f0d8a4865ca57ae73c6b /crypto/src/util/Platform.cs
parentupdate build script (diff)
parentMerge branch 'master' of git.bouncycastle.org:bc-csharp into pcl (diff)
downloadBouncyCastle.NET-ed25519-c2bc6d18b888c0a3d3d1177e7c049f042dcae3ac.tar.xz
Merge pull request #14 from peterdettman/pcl
Updates everything to the bc-csharp 1.8.0 release tag
Diffstat (limited to 'crypto/src/util/Platform.cs')
-rw-r--r--crypto/src/util/Platform.cs39
1 files changed, 31 insertions, 8 deletions
diff --git a/crypto/src/util/Platform.cs b/crypto/src/util/Platform.cs

index d4b18f182..86484854d 100644 --- a/crypto/src/util/Platform.cs +++ b/crypto/src/util/Platform.cs
@@ -13,6 +13,8 @@ namespace Org.BouncyCastle.Utilities { internal abstract class Platform { + private static readonly CompareInfo InvariantCompareInfo = CultureInfo.InvariantCulture.CompareInfo; + #if NETCF_1_0 || NETCF_2_0 private static string GetNewLine() { @@ -30,16 +32,12 @@ namespace Org.BouncyCastle.Utilities } #endif - internal static int CompareIgnoreCase(string a, string b) + internal static bool EqualsIgnoreCase(string a, string b) { -#if SILVERLIGHT - return String.Compare(a, b, StringComparison.InvariantCultureIgnoreCase); -#elif SYS_RUNTIME - return String.Compare(a, b, StringComparison.OrdinalIgnoreCase); -#elif PORTABLE - return String.Compare(a, b, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase); +#if PORTABLE + return String.Equals(a, b, StringComparison.OrdinalIgnoreCase); #else - return String.Compare(a, b, true); + return ToUpperInvariant(a) == ToUpperInvariant(b); #endif } @@ -202,5 +200,30 @@ namespace Org.BouncyCastle.Utilities t.Close(); } #endif + + internal static int IndexOf(string source, string value) + { + return InvariantCompareInfo.IndexOf(source, value, CompareOptions.Ordinal); + } + + internal static int LastIndexOf(string source, string value) + { + return InvariantCompareInfo.LastIndexOf(source, value, CompareOptions.Ordinal); + } + + internal static bool StartsWith(string source, string prefix) + { + return InvariantCompareInfo.IsPrefix(source, prefix, CompareOptions.Ordinal); + } + + internal static bool EndsWith(string source, string suffix) + { + return InvariantCompareInfo.IsSuffix(source, suffix, CompareOptions.Ordinal); + } + + internal static string GetTypeName(object obj) + { + return obj.GetType().FullName; + } } }