Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (31 sloc) 0.914 kb
using System;
namespace FluentCassandra.Types
{
internal class DoubleTypeConverter : CassandraObjectConverter<double>
{
public override bool CanConvertFrom(Type sourceType)
{
if (Type.GetTypeCode(sourceType) != TypeCode.Object)
return true;
return sourceType == typeof(byte[]);
}
public override bool CanConvertTo(Type destinationType)
{
if (Type.GetTypeCode(destinationType) != TypeCode.Object)
return true;
return destinationType == typeof(byte[]);
}
public override double ConvertFromInternal(object value)
{
if (value is byte[])
return ((byte[])value).FromBytes<double>();
return (double)Convert.ChangeType(value, typeof(double));
}
public override object ConvertToInternal(double value, Type destinationType)
{
if (destinationType == typeof(byte[]))
return value.ToBytes();
return Convert.ChangeType(value, destinationType);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.