From 31525ff4a76773fa0cc85d4abcee7d5418cbd984 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 21 Jan 2014 14:51:32 +0700 Subject: Make static utility classes abstract instead of sealed Add Arrays.GetHashCode for int[] Formatting --- crypto/src/util/Platform.cs | 96 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 50 deletions(-) (limited to 'crypto/src/util/Platform.cs') diff --git a/crypto/src/util/Platform.cs b/crypto/src/util/Platform.cs index cdfba789e..99d3982ea 100644 --- a/crypto/src/util/Platform.cs +++ b/crypto/src/util/Platform.cs @@ -11,22 +11,18 @@ using System.Collections; namespace Org.BouncyCastle.Utilities { - internal sealed class Platform - { - private Platform() - { - } - + internal abstract class Platform + { #if NETCF_1_0 || NETCF_2_0 - private static string GetNewLine() - { - MemoryStream buf = new MemoryStream(); - StreamWriter w = new StreamWriter(buf, Encoding.UTF8); - w.WriteLine(); - w.Close(); - byte[] bs = buf.ToArray(); + private static string GetNewLine() + { + MemoryStream buf = new MemoryStream(); + StreamWriter w = new StreamWriter(buf, Encoding.UTF8); + w.WriteLine(); + w.Close(); + byte[] bs = buf.ToArray(); return Encoding.UTF8.GetString(bs, 0, bs.Length); - } + } #else private static string GetNewLine() { @@ -44,47 +40,47 @@ namespace Org.BouncyCastle.Utilities } #if NETCF_1_0 || NETCF_2_0 || SILVERLIGHT - internal static string GetEnvironmentVariable( - string variable) - { - return null; - } + internal static string GetEnvironmentVariable( + string variable) + { + return null; + } #else - internal static string GetEnvironmentVariable( - string variable) - { - try - { - return Environment.GetEnvironmentVariable(variable); - } - catch (System.Security.SecurityException) - { - // We don't have the required permission to read this environment variable, - // which is fine, just act as if it's not set - return null; - } - } + internal static string GetEnvironmentVariable( + string variable) + { + try + { + return Environment.GetEnvironmentVariable(variable); + } + catch (System.Security.SecurityException) + { + // We don't have the required permission to read this environment variable, + // which is fine, just act as if it's not set + return null; + } + } #endif #if NETCF_1_0 - internal static Exception CreateNotImplementedException( - string message) - { - return new Exception("Not implemented: " + message); - } + internal static Exception CreateNotImplementedException( + string message) + { + return new Exception("Not implemented: " + message); + } - internal static bool Equals( - object a, - object b) - { - return a == b || (a != null && b != null && a.Equals(b)); - } + internal static bool Equals( + object a, + object b) + { + return a == b || (a != null && b != null && a.Equals(b)); + } #else - internal static Exception CreateNotImplementedException( - string message) - { - return new NotImplementedException(message); - } + internal static Exception CreateNotImplementedException( + string message) + { + return new NotImplementedException(message); + } #endif #if SILVERLIGHT @@ -178,5 +174,5 @@ namespace Org.BouncyCastle.Utilities } internal static readonly string NewLine = GetNewLine(); - } + } } -- cgit 1.4.1