Skip to content

Commit

Permalink
Minor clean-up. Made several things public again.
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Jan 29, 2016
1 parent 1fb9bcc commit 8e97374
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
20 changes: 20 additions & 0 deletions MaxMind.Db/Buffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ internal BigInteger ReadBigInteger(long offset, int size)
return new BigInteger(buffer);
}

/// <summary>
/// Read a double from the buffer.
/// </summary>
internal double ReadDouble(long offset)
{
var buffer = Read(offset, 8);
Array.Reverse(buffer);
return BitConverter.ToDouble(buffer, 0);
}

/// <summary>
/// Read a float from the buffer.
/// </summary>
internal float ReadFloat(long offset)
{
var buffer = Read(offset, 4);
Array.Reverse(buffer);
return BitConverter.ToSingle(buffer, 0);
}

/// <summary>
/// Read an integer from the buffer.
/// </summary>
Expand Down
8 changes: 2 additions & 6 deletions MaxMind.Db/Decoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,7 @@ private double DecodeDouble(Type expectedType, long offset, int size)
if (size != 8)
throw new InvalidDatabaseException("The MaxMind DB file's data section contains bad data: "
+ "invalid size of double.");
var buffer = _database.Read(offset, size);
Array.Reverse(buffer);
return BitConverter.ToDouble(buffer, 0);
return _database.ReadDouble(offset);
}

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

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions MaxMind.Db/DeserializationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class DeserializationException : Exception
/// Construct a DeserializationException
/// </summary>
/// <param name="message"></param>
internal DeserializationException(string message)
public DeserializationException(string message)
: base(message)
{
}
Expand All @@ -29,7 +29,7 @@ internal DeserializationException(string message)
/// </summary>
/// <param name="message"></param>
/// <param name="innerException">The underlying exception that caused this one.</param>
private DeserializationException(string message, Exception innerException)
public DeserializationException(string message, Exception innerException)
: base(message, innerException)
{
}
Expand Down
4 changes: 2 additions & 2 deletions MaxMind.Db/InvalidDatabaseException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class InvalidDatabaseException : Exception
/// Initializes a new instance of the <see cref="InvalidDatabaseException" /> class.
/// </summary>
/// <param name="message">A message that describes the error.</param>
internal InvalidDatabaseException(string message)
public InvalidDatabaseException(string message)
: base(message)
{
}
Expand All @@ -31,7 +31,7 @@ internal InvalidDatabaseException(string message)
/// <paramref name="innerException" /> parameter is not a null reference, the current exception is raised in a catch
/// block that handles the inner exception.
/// </param>
private InvalidDatabaseException(string message, Exception innerException)
public InvalidDatabaseException(string message, Exception innerException)
: base(message, innerException)
{
}
Expand Down
2 changes: 2 additions & 0 deletions MaxMind.Db/MaxMind.Db.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>MaxMind.Db.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -59,6 +60,7 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>MaxMind.Db.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
4 changes: 2 additions & 2 deletions MaxMind.Db/ParameterAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public sealed class ParameterAttribute : Attribute
/// <summary>
/// The name to use for the property.
/// </summary>
internal string ParameterName { get; }
public string ParameterName { get; }

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

/// <summary>
/// Create a new instance of <code>ParameterAttribute</code>.
Expand Down
2 changes: 1 addition & 1 deletion MaxMind.Db/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0-beta1")]
[assembly: AssemblyInformationalVersion("2.0.0-beta2")]
[assembly: InternalsVisibleTo("MaxMind.Db.Test,PublicKey=" +
"0024000004800000940000000602000000240000525341310004000001000100e30b6e4a9425b1" +
"617ffc8bdf79801e67a371f9f650db860dc0dfff92cb63258765a0955c6fcde1da78dbaf5bf84d" +
Expand Down

0 comments on commit 8e97374

Please sign in to comment.