Skip to content

Commit 8e97374

Browse files
committed
Minor clean-up. Made several things public again.
1 parent 1fb9bcc commit 8e97374

File tree

7 files changed

+31
-13
lines changed

7 files changed

+31
-13
lines changed

MaxMind.Db/Buffer.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ internal BigInteger ReadBigInteger(long offset, int size)
4444
return new BigInteger(buffer);
4545
}
4646

47+
/// <summary>
48+
/// Read a double from the buffer.
49+
/// </summary>
50+
internal double ReadDouble(long offset)
51+
{
52+
var buffer = Read(offset, 8);
53+
Array.Reverse(buffer);
54+
return BitConverter.ToDouble(buffer, 0);
55+
}
56+
57+
/// <summary>
58+
/// Read a float from the buffer.
59+
/// </summary>
60+
internal float ReadFloat(long offset)
61+
{
62+
var buffer = Read(offset, 4);
63+
Array.Reverse(buffer);
64+
return BitConverter.ToSingle(buffer, 0);
65+
}
66+
4767
/// <summary>
4868
/// Read an integer from the buffer.
4969
/// </summary>

MaxMind.Db/Decoder.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ private double DecodeDouble(Type expectedType, long offset, int size)
236236
if (size != 8)
237237
throw new InvalidDatabaseException("The MaxMind DB file's data section contains bad data: "
238238
+ "invalid size of double.");
239-
var buffer = _database.Read(offset, size);
240-
Array.Reverse(buffer);
241-
return BitConverter.ToDouble(buffer, 0);
239+
return _database.ReadDouble(offset);
242240
}
243241

244242
/// <summary>
@@ -252,9 +250,7 @@ private float DecodeFloat(Type expectedType, long offset, int size)
252250
if (size != 4)
253251
throw new InvalidDatabaseException("The MaxMind DB file's data section contains bad data: "
254252
+ "invalid size of float.");
255-
var buffer = _database.Read(offset, size);
256-
Array.Reverse(buffer);
257-
return BitConverter.ToSingle(buffer, 0);
253+
return _database.ReadFloat(offset);
258254
}
259255

260256
/// <summary>

MaxMind.Db/DeserializationException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public sealed class DeserializationException : Exception
1919
/// Construct a DeserializationException
2020
/// </summary>
2121
/// <param name="message"></param>
22-
internal DeserializationException(string message)
22+
public DeserializationException(string message)
2323
: base(message)
2424
{
2525
}
@@ -29,7 +29,7 @@ internal DeserializationException(string message)
2929
/// </summary>
3030
/// <param name="message"></param>
3131
/// <param name="innerException">The underlying exception that caused this one.</param>
32-
private DeserializationException(string message, Exception innerException)
32+
public DeserializationException(string message, Exception innerException)
3333
: base(message, innerException)
3434
{
3535
}

MaxMind.Db/InvalidDatabaseException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed class InvalidDatabaseException : Exception
1717
/// Initializes a new instance of the <see cref="InvalidDatabaseException" /> class.
1818
/// </summary>
1919
/// <param name="message">A message that describes the error.</param>
20-
internal InvalidDatabaseException(string message)
20+
public InvalidDatabaseException(string message)
2121
: base(message)
2222
{
2323
}
@@ -31,7 +31,7 @@ internal InvalidDatabaseException(string message)
3131
/// <paramref name="innerException" /> parameter is not a null reference, the current exception is raised in a catch
3232
/// block that handles the inner exception.
3333
/// </param>
34-
private InvalidDatabaseException(string message, Exception innerException)
34+
public InvalidDatabaseException(string message, Exception innerException)
3535
: base(message, innerException)
3636
{
3737
}

MaxMind.Db/MaxMind.Db.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<WarningLevel>4</WarningLevel>
4747
<CodeAnalysisRuleSet>MaxMind.Db.ruleset</CodeAnalysisRuleSet>
4848
<Prefer32Bit>false</Prefer32Bit>
49+
<RunCodeAnalysis>true</RunCodeAnalysis>
4950
</PropertyGroup>
5051
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
5152
<DebugType>pdbonly</DebugType>
@@ -59,6 +60,7 @@
5960
<RunCodeAnalysis>true</RunCodeAnalysis>
6061
<CodeAnalysisRuleSet>MaxMind.Db.ruleset</CodeAnalysisRuleSet>
6162
<Prefer32Bit>false</Prefer32Bit>
63+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
6264
</PropertyGroup>
6365
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
6466
<DebugSymbols>true</DebugSymbols>

MaxMind.Db/ParameterAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public sealed class ParameterAttribute : Attribute
1515
/// <summary>
1616
/// The name to use for the property.
1717
/// </summary>
18-
internal string ParameterName { get; }
18+
public string ParameterName { get; }
1919

2020
/// <summary>
2121
/// Whether to create the object even if the key is not present in
2222
/// the database. If this is false, the default value will be used
2323
/// (null for nullable types).
2424
/// </summary>
25-
internal bool AlwaysCreate { get; }
25+
public bool AlwaysCreate { get; }
2626

2727
/// <summary>
2828
/// Create a new instance of <code>ParameterAttribute</code>.

MaxMind.Db/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
[assembly: AssemblyVersion("2.0.0")]
4646
[assembly: AssemblyFileVersion("2.0.0")]
47-
[assembly: AssemblyInformationalVersion("2.0.0-beta1")]
47+
[assembly: AssemblyInformationalVersion("2.0.0-beta2")]
4848
[assembly: InternalsVisibleTo("MaxMind.Db.Test,PublicKey=" +
4949
"0024000004800000940000000602000000240000525341310004000001000100e30b6e4a9425b1" +
5050
"617ffc8bdf79801e67a371f9f650db860dc0dfff92cb63258765a0955c6fcde1da78dbaf5bf84d" +

0 commit comments

Comments
 (0)