diff options
author | Jon Skeet <skeet@pobox.com> | 2015-06-19 17:30:13 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2015-06-19 17:30:13 +0100 |
commit | cdeda4b87625084f5687115bb1fd7772b7c34ad6 (patch) | |
tree | 373f4c38dbfb318626037ff204c30466574ab876 /csharp/src/ProtocolBuffers/FrameworkPortability.cs | |
parent | d7dda2fed8c37a83e2d4cd7ecc4201b628588c4c (diff) | |
download | protobuf-cdeda4b87625084f5687115bb1fd7772b7c34ad6.tar.gz protobuf-cdeda4b87625084f5687115bb1fd7772b7c34ad6.tar.bz2 protobuf-cdeda4b87625084f5687115bb1fd7772b7c34ad6.zip |
Minor cleanup.
- Make some members internal
- Remove a lot of FrameworkPortability that isn't required
- Start adding documentation comments
- Remove some more group-based members
- Not passing in "the last tag read" into Read*Array, g
Diffstat (limited to 'csharp/src/ProtocolBuffers/FrameworkPortability.cs')
-rw-r--r-- | csharp/src/ProtocolBuffers/FrameworkPortability.cs | 68 |
1 files changed, 5 insertions, 63 deletions
diff --git a/csharp/src/ProtocolBuffers/FrameworkPortability.cs b/csharp/src/ProtocolBuffers/FrameworkPortability.cs index 5fa7c4e7..06246a9e 100644 --- a/csharp/src/ProtocolBuffers/FrameworkPortability.cs +++ b/csharp/src/ProtocolBuffers/FrameworkPortability.cs @@ -35,8 +35,6 @@ #endregion
using System;
-using System.Globalization;
-using System.Reflection;
using System.Text.RegularExpressions;
namespace Google.Protobuf
@@ -46,66 +44,10 @@ namespace Google.Protobuf /// </summary>
internal static class FrameworkPortability
{
-#if COMPACT_FRAMEWORK
- internal const string NewLine = "\n";
-#else
- internal static readonly string NewLine = System.Environment.NewLine;
-#endif
-
-#if CLIENTPROFILE
- internal const RegexOptions CompiledRegexWhereAvailable = RegexOptions.Compiled;
-#else
- internal const RegexOptions CompiledRegexWhereAvailable = RegexOptions.None;
-#endif
-
- internal static CultureInfo InvariantCulture
- {
- get { return CultureInfo.InvariantCulture; }
- }
-
- internal static double Int64ToDouble(long value)
- {
-#if CLIENTPROFILE
- return BitConverter.Int64BitsToDouble(value);
-#else
- double[] arresult = new double[1];
- Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
- return arresult[0];
-#endif
- }
-
- internal static long DoubleToInt64(double value)
- {
-#if CLIENTPROFILE
- return BitConverter.DoubleToInt64Bits(value);
-#else
- long[] arresult = new long[1];
- Buffer.BlockCopy(new[] { value }, 0, arresult, 0, 8);
- return arresult[0];
-#endif
- }
-
- internal static bool TryParseInt32(string text, out int number)
- {
- return TryParseInt32(text, NumberStyles.Any, InvariantCulture, out number);
- }
-
- internal static bool TryParseInt32(string text, NumberStyles style, IFormatProvider format, out int number)
- {
-#if COMPACT_FRAMEWORK
- try
- {
- number = int.Parse(text, style, format);
- return true;
- }
- catch
- {
- number = 0;
- return false;
- }
-#else
- return int.TryParse(text, style, format, out number);
-#endif
- }
+ // The value of RegexOptions.Compiled is 8. We can test for the presence at
+ // execution time using Enum.IsDefined, so a single build will do the right thing
+ // on each platform.
+ internal static readonly RegexOptions CompiledRegexWhereAvailable =
+ Enum.IsDefined(typeof(RegexOptions), 8) ? (RegexOptions)8 : RegexOptions.None;
}
}
\ No newline at end of file |