You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
970 B
42 lines
970 B
using System;
|
|
using Marr.Data.Converters;
|
|
using Marr.Data.Mapping;
|
|
|
|
namespace NzbDrone.Core.Datastore.Converters
|
|
{
|
|
public class EnumIntConverter : IConverter
|
|
{
|
|
public Type DbType
|
|
{
|
|
get
|
|
{
|
|
return typeof(int);
|
|
}
|
|
}
|
|
|
|
public object FromDB(ConverterContext context)
|
|
{
|
|
if (context.DbValue != null && context.DbValue != DBNull.Value)
|
|
{
|
|
return Enum.ToObject(context.ColumnMap.FieldType, (Int64)context.DbValue);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public object FromDB(ColumnMap map, object dbValue)
|
|
{
|
|
return FromDB(new ConverterContext { ColumnMap = map, DbValue = dbValue });
|
|
}
|
|
|
|
public object ToDB(object clrValue)
|
|
{
|
|
if (clrValue != null)
|
|
{
|
|
return (int)clrValue;
|
|
}
|
|
|
|
return DBNull.Value;
|
|
}
|
|
}
|
|
} |