Class BsonUtils
A static class containing BSON utility methods.
public static class BsonUtils
- Inheritance
-
BsonUtils
- Inherited Members
Methods
GetFriendlyTypeName(Type)
Gets a friendly class name suitable for use in error messages.
public static string GetFriendlyTypeName(Type type)
Parameters
typeTypeThe type.
Returns
- string
A friendly class name.
ParseHexString(string)
Parses a hex string into its equivalent byte array.
public static byte[] ParseHexString(string s)
Parameters
sstringThe hex string to parse.
Returns
- byte[]
The byte equivalent of the hex string.
ToDateTimeFromMillisecondsSinceEpoch(long)
Converts from number of milliseconds since Unix epoch to DateTime.
public static DateTime ToDateTimeFromMillisecondsSinceEpoch(long millisecondsSinceEpoch)
Parameters
millisecondsSinceEpochlongThe number of milliseconds since Unix epoch.
Returns
- DateTime
A DateTime.
ToHexChar(int)
Converts a value to a hex character.
public static char ToHexChar(int value)
Parameters
valueintThe value (assumed to be between 0 and 15).
Returns
- char
The hex character.
ToHexString(byte[])
Converts a byte array to a hex string.
public static string ToHexString(byte[] bytes)
Parameters
bytesbyte[]The byte array.
Returns
- string
A hex string.
ToLocalTime(DateTime)
Converts a DateTime to local time (with special handling for MinValue and MaxValue).
public static DateTime ToLocalTime(DateTime dateTime)
Parameters
dateTimeDateTimeA DateTime.
Returns
- DateTime
The DateTime in local time.
ToMillisecondsSinceEpoch(DateTime)
Converts a DateTime to number of milliseconds since Unix epoch.
public static long ToMillisecondsSinceEpoch(DateTime dateTime)
Parameters
dateTimeDateTimeA DateTime.
Returns
- long
Number of milliseconds since Unix epoch.
ToSecondsSinceEpoch(DateTime)
Converts a DateTime to number of seconds since Unix epoch.
public static long ToSecondsSinceEpoch(DateTime dateTime)
Parameters
dateTimeDateTimeA DateTime.
Returns
- long
Number of seconds since Unix epoch.
ToUniversalTime(DateTime)
Converts a DateTime to UTC (with special handling for MinValue and MaxValue).
public static DateTime ToUniversalTime(DateTime dateTime)
Parameters
dateTimeDateTimeA DateTime.
Returns
- DateTime
The DateTime in UTC.
TryParseHexString(string, out byte[])
Tries to parse a hex string to a byte array.
public static bool TryParseHexString(string s, out byte[] bytes)
Parameters
Returns
- bool
True if the hex string was successfully parsed.