mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
removed code redundancies.
This commit is contained in:
parent
6d3a604677
commit
9a24268ee7
@ -93,12 +93,9 @@ internal string GetTypeAssemblyName(Type t)
|
|||||||
string val = "";
|
string val = "";
|
||||||
if (_tyname.TryGetValue(t, out val))
|
if (_tyname.TryGetValue(t, out val))
|
||||||
return val;
|
return val;
|
||||||
else
|
string s = t.AssemblyQualifiedName;
|
||||||
{
|
_tyname.Add(t, s);
|
||||||
string s = t.AssemblyQualifiedName;
|
return s;
|
||||||
_tyname.Add(t, s);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly SafeDictionary<string, Type> _typecache = new SafeDictionary<string, Type>();
|
readonly SafeDictionary<string, Type> _typecache = new SafeDictionary<string, Type>();
|
||||||
@ -107,12 +104,9 @@ private Type GetTypeFromCache(string typename)
|
|||||||
Type val = null;
|
Type val = null;
|
||||||
if (_typecache.TryGetValue(typename, out val))
|
if (_typecache.TryGetValue(typename, out val))
|
||||||
return val;
|
return val;
|
||||||
else
|
Type t = Type.GetType(typename);
|
||||||
{
|
_typecache.Add(typename, t);
|
||||||
Type t = Type.GetType(typename);
|
return t;
|
||||||
_typecache.Add(typename, t);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly SafeDictionary<Type, CreateObject> _constrcache = new SafeDictionary<Type, CreateObject>();
|
readonly SafeDictionary<Type, CreateObject> _constrcache = new SafeDictionary<Type, CreateObject>();
|
||||||
@ -126,17 +120,14 @@ private object FastCreateInstance(Type objtype)
|
|||||||
{
|
{
|
||||||
return c();
|
return c();
|
||||||
}
|
}
|
||||||
else
|
DynamicMethod dynMethod = new DynamicMethod("_", objtype, null, true);
|
||||||
{
|
ILGenerator ilGen = dynMethod.GetILGenerator();
|
||||||
DynamicMethod dynMethod = new DynamicMethod("_", objtype, null, true);
|
|
||||||
ILGenerator ilGen = dynMethod.GetILGenerator();
|
|
||||||
|
|
||||||
ilGen.Emit(OpCodes.Newobj, objtype.GetConstructor(Type.EmptyTypes));
|
ilGen.Emit(OpCodes.Newobj, objtype.GetConstructor(Type.EmptyTypes));
|
||||||
ilGen.Emit(OpCodes.Ret);
|
ilGen.Emit(OpCodes.Ret);
|
||||||
c = (CreateObject)dynMethod.CreateDelegate(typeof(CreateObject));
|
c = (CreateObject)dynMethod.CreateDelegate(typeof(CreateObject));
|
||||||
_constrcache.Add(objtype, c);
|
_constrcache.Add(objtype, c);
|
||||||
return c();
|
return c();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
catch (Exception exc)
|
||||||
{
|
{
|
||||||
@ -188,22 +179,19 @@ private SafeDictionary<string, myPropInfo> Getproperties(Type type, string typen
|
|||||||
{
|
{
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
else
|
sd = new SafeDictionary<string, myPropInfo>();
|
||||||
|
var pr = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||||||
|
foreach (var p in pr)
|
||||||
{
|
{
|
||||||
sd = new SafeDictionary<string, myPropInfo>();
|
myPropInfo d = CreateMyProp(p.PropertyType, p.Name);
|
||||||
var pr = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
d.CanWrite = p.CanWrite;
|
||||||
foreach (var p in pr)
|
d.setter = CreateSetMethod(p);
|
||||||
{
|
d.getter = CreateGetMethod(p);
|
||||||
myPropInfo d = CreateMyProp(p.PropertyType, p.Name);
|
sd.Add(p.Name, d);
|
||||||
d.CanWrite = p.CanWrite;
|
|
||||||
d.setter = CreateSetMethod(p);
|
|
||||||
d.getter = CreateGetMethod(p);
|
|
||||||
sd.Add(p.Name, d);
|
|
||||||
}
|
|
||||||
|
|
||||||
_propertycache.Add(typename, sd);
|
|
||||||
return sd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_propertycache.Add(typename, sd);
|
||||||
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
private myPropInfo CreateMyProp(Type t, string name)
|
private myPropInfo CreateMyProp(Type t, string name)
|
||||||
@ -342,16 +330,16 @@ private object ChangeType(object value, Type conversionType)
|
|||||||
if (conversionType == typeof(int))
|
if (conversionType == typeof(int))
|
||||||
return (int)CreateLong((string)value);
|
return (int)CreateLong((string)value);
|
||||||
|
|
||||||
else if (conversionType == typeof(long))
|
if (conversionType == typeof(long))
|
||||||
return CreateLong((string)value);
|
return CreateLong((string)value);
|
||||||
|
|
||||||
else if (conversionType == typeof(string))
|
if (conversionType == typeof(string))
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
else if (conversionType == typeof(Guid))
|
if (conversionType == typeof(Guid))
|
||||||
return CreateGuid((string)value);
|
return CreateGuid((string)value);
|
||||||
|
|
||||||
else if (conversionType.IsEnum)
|
if (conversionType.IsEnum)
|
||||||
return CreateEnum(conversionType, (string)value);
|
return CreateEnum(conversionType, (string)value);
|
||||||
|
|
||||||
return Convert.ChangeType(value, conversionType, CultureInfo.InvariantCulture);
|
return Convert.ChangeType(value, conversionType, CultureInfo.InvariantCulture);
|
||||||
@ -550,8 +538,7 @@ private Guid CreateGuid(string s)
|
|||||||
{
|
{
|
||||||
if (s.Length > 30)
|
if (s.Length > 30)
|
||||||
return new Guid(s);
|
return new Guid(s);
|
||||||
else
|
return new Guid(Convert.FromBase64String(s));
|
||||||
return new Guid(Convert.FromBase64String(s));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateTime CreateDateTime(string value)
|
private DateTime CreateDateTime(string value)
|
||||||
@ -571,8 +558,7 @@ private DateTime CreateDateTime(string value)
|
|||||||
|
|
||||||
if (UseUTCDateTime == false && utc == false)
|
if (UseUTCDateTime == false && utc == false)
|
||||||
return new DateTime(year, month, day, hour, min, sec);
|
return new DateTime(year, month, day, hour, min, sec);
|
||||||
else
|
return new DateTime(year, month, day, hour, min, sec, DateTimeKind.Utc).ToLocalTime();
|
||||||
return new DateTime(year, month, day, hour, min, sec, DateTimeKind.Utc).ToLocalTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SILVERLIGHT
|
#if SILVERLIGHT
|
||||||
|
@ -33,17 +33,14 @@ public object FromDB(ColumnMap map, object dbValue)
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
throw new ConversionException(
|
||||||
{
|
string.Format(
|
||||||
throw new ConversionException(
|
|
||||||
string.Format(
|
|
||||||
"The BooleanCharConverter could not convert the value '{0}' to a boolean.",
|
"The BooleanCharConverter could not convert the value '{0}' to a boolean.",
|
||||||
dbValue));
|
dbValue));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ToDB(object clrValue)
|
public object ToDB(object clrValue)
|
||||||
@ -54,14 +51,11 @@ public object ToDB(object clrValue)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (val == false)
|
if (val == false)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
return DBNull.Value;
|
||||||
{
|
|
||||||
return DBNull.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type DbType
|
public Type DbType
|
||||||
|
@ -33,17 +33,14 @@ public object FromDB(ColumnMap map, object dbValue)
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (val == "N")
|
if (val == "N")
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
throw new ConversionException(
|
||||||
{
|
string.Format(
|
||||||
throw new ConversionException(
|
|
||||||
string.Format(
|
|
||||||
"The BooleanYNConverter could not convert the value '{0}' to a boolean.",
|
"The BooleanYNConverter could not convert the value '{0}' to a boolean.",
|
||||||
dbValue));
|
dbValue));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ToDB(object clrValue)
|
public object ToDB(object clrValue)
|
||||||
@ -54,14 +51,11 @@ public object ToDB(object clrValue)
|
|||||||
{
|
{
|
||||||
return "Y";
|
return "Y";
|
||||||
}
|
}
|
||||||
else if (val == false)
|
if (val == false)
|
||||||
{
|
{
|
||||||
return "N";
|
return "N";
|
||||||
}
|
}
|
||||||
else
|
return DBNull.Value;
|
||||||
{
|
|
||||||
return DBNull.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type DbType
|
public Type DbType
|
||||||
|
@ -24,16 +24,14 @@ public object FromDB(ColumnMap map, object dbValue)
|
|||||||
{
|
{
|
||||||
if (dbValue == null || dbValue == DBNull.Value)
|
if (dbValue == null || dbValue == DBNull.Value)
|
||||||
return null;
|
return null;
|
||||||
else
|
return Enum.ToObject(map.FieldType, (int)dbValue);
|
||||||
return Enum.ToObject(map.FieldType, (int)dbValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ToDB(object clrValue)
|
public object ToDB(object clrValue)
|
||||||
{
|
{
|
||||||
if (clrValue == null)
|
if (clrValue == null)
|
||||||
return DBNull.Value;
|
return DBNull.Value;
|
||||||
else
|
return (int)clrValue;
|
||||||
return (int)clrValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type DbType
|
public Type DbType
|
||||||
|
@ -24,16 +24,14 @@ public object FromDB(ColumnMap map, object dbValue)
|
|||||||
{
|
{
|
||||||
if (dbValue == null || dbValue == DBNull.Value)
|
if (dbValue == null || dbValue == DBNull.Value)
|
||||||
return null;
|
return null;
|
||||||
else
|
return Enum.Parse(map.FieldType, (string)dbValue);
|
||||||
return Enum.Parse(map.FieldType, (string)dbValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object ToDB(object clrValue)
|
public object ToDB(object clrValue)
|
||||||
{
|
{
|
||||||
if (clrValue == null)
|
if (clrValue == null)
|
||||||
return DBNull.Value;
|
return DBNull.Value;
|
||||||
else
|
return clrValue.ToString();
|
||||||
return clrValue.ToString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type DbType
|
public Type DbType
|
||||||
|
@ -65,10 +65,7 @@ public static string GetColumName(this IColumnInfo col, bool useAltName)
|
|||||||
{
|
{
|
||||||
return col.TryGetAltName();
|
return col.TryGetAltName();
|
||||||
}
|
}
|
||||||
else
|
return col.Name;
|
||||||
{
|
|
||||||
return col.Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -174,8 +174,7 @@ public object ExecuteScalar(string sql)
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sql))
|
if (string.IsNullOrEmpty(sql))
|
||||||
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
|
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
|
||||||
else
|
Command.CommandText = sql;
|
||||||
Command.CommandText = sql;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -197,8 +196,7 @@ public int ExecuteNonQuery(string sql)
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sql))
|
if (string.IsNullOrEmpty(sql))
|
||||||
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
|
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
|
||||||
else
|
Command.CommandText = sql;
|
||||||
Command.CommandText = sql;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -223,8 +221,7 @@ public IEnumerable<TResult> ExecuteReader<TResult>(string sql, Func<DbDataReader
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sql))
|
if (string.IsNullOrEmpty(sql))
|
||||||
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
|
throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");
|
||||||
else
|
Command.CommandText = sql;
|
||||||
Command.CommandText = sql;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -105,11 +105,8 @@ private IMapStrategy GetMapStrategy(Type entityType)
|
|||||||
// Return entity specific column map strategy
|
// Return entity specific column map strategy
|
||||||
return _columnMapStrategies[entityType];
|
return _columnMapStrategies[entityType];
|
||||||
}
|
}
|
||||||
else
|
// Return the default column map strategy
|
||||||
{
|
return _columnMapStrategies[typeof(object)];
|
||||||
// Return the default column map strategy
|
|
||||||
return _columnMapStrategies[typeof(object)];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -219,21 +216,18 @@ internal IConverter GetConverter(Type dataType)
|
|||||||
// User registered type converter
|
// User registered type converter
|
||||||
return TypeConverters[dataType];
|
return TypeConverters[dataType];
|
||||||
}
|
}
|
||||||
else if (TypeConverters.ContainsKey(typeof(Enum)) && dataType.IsEnum)
|
if (TypeConverters.ContainsKey(typeof(Enum)) && dataType.IsEnum)
|
||||||
{
|
{
|
||||||
// A converter is registered to handled enums
|
// A converter is registered to handled enums
|
||||||
return TypeConverters[typeof(Enum)];
|
return TypeConverters[typeof(Enum)];
|
||||||
}
|
}
|
||||||
else if (TypeConverters.ContainsKey(typeof(object)))
|
if (TypeConverters.ContainsKey(typeof(object)))
|
||||||
{
|
{
|
||||||
// User registered default converter
|
// User registered default converter
|
||||||
return TypeConverters[typeof(object)];
|
return TypeConverters[typeof(object)];
|
||||||
}
|
}
|
||||||
else
|
// No conversion
|
||||||
{
|
return null;
|
||||||
// No conversion
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -109,10 +109,7 @@ public string TryGetAltName()
|
|||||||
{
|
{
|
||||||
return AltName;
|
return AltName;
|
||||||
}
|
}
|
||||||
else
|
return Name;
|
||||||
{
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,7 @@ public string TryGetAltName()
|
|||||||
{
|
{
|
||||||
return AltName;
|
return AltName;
|
||||||
}
|
}
|
||||||
else
|
return Name;
|
||||||
{
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,10 +216,7 @@ private void TryAddColumnMapForField(string fieldName)
|
|||||||
fieldName,
|
fieldName,
|
||||||
typeof(TEntity).Name));
|
typeof(TEntity).Name));
|
||||||
}
|
}
|
||||||
else
|
MappedColumns.Add(columnMap);
|
||||||
{
|
|
||||||
MappedColumns.Add(columnMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -153,10 +153,7 @@ private void TryAddRelationshipForField(string fieldName)
|
|||||||
fieldName,
|
fieldName,
|
||||||
typeof(TEntity).Name));
|
typeof(TEntity).Name));
|
||||||
}
|
}
|
||||||
else
|
Relationships.Add(relationship);
|
||||||
{
|
|
||||||
Relationships.Add(relationship);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -67,10 +67,7 @@ public string MapTable(Type entityType)
|
|||||||
{
|
{
|
||||||
return (atts[0] as TableAttribute).Name;
|
return (atts[0] as TableAttribute).Name;
|
||||||
}
|
}
|
||||||
else
|
return entityType.Name;
|
||||||
{
|
|
||||||
return entityType.Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -25,41 +25,40 @@ public Enum GetDbType(Type type)
|
|||||||
if (type == typeof(String))
|
if (type == typeof(String))
|
||||||
return DbType.String;
|
return DbType.String;
|
||||||
|
|
||||||
else if (type == typeof(Int32))
|
if (type == typeof(Int32))
|
||||||
return DbType.Int32;
|
return DbType.Int32;
|
||||||
|
|
||||||
else if (type == typeof(Decimal))
|
if (type == typeof(Decimal))
|
||||||
return DbType.Decimal;
|
return DbType.Decimal;
|
||||||
|
|
||||||
else if (type == typeof(DateTime))
|
if (type == typeof(DateTime))
|
||||||
return DbType.DateTime;
|
return DbType.DateTime;
|
||||||
|
|
||||||
else if (type == typeof(Boolean))
|
if (type == typeof(Boolean))
|
||||||
return DbType.Boolean;
|
return DbType.Boolean;
|
||||||
|
|
||||||
else if (type == typeof(Int16))
|
if (type == typeof(Int16))
|
||||||
return DbType.Int16;
|
return DbType.Int16;
|
||||||
|
|
||||||
else if (type == typeof(Single))
|
if (type == typeof(Single))
|
||||||
return DbType.Single;
|
return DbType.Single;
|
||||||
|
|
||||||
else if (type == typeof(Int64))
|
if (type == typeof(Int64))
|
||||||
return DbType.Int64;
|
return DbType.Int64;
|
||||||
|
|
||||||
else if (type == typeof(Double))
|
if (type == typeof(Double))
|
||||||
return DbType.Double;
|
return DbType.Double;
|
||||||
|
|
||||||
else if (type == typeof(Byte))
|
if (type == typeof(Byte))
|
||||||
return DbType.Byte;
|
return DbType.Byte;
|
||||||
|
|
||||||
else if (type == typeof(Byte[]))
|
if (type == typeof(Byte[]))
|
||||||
return DbType.Binary;
|
return DbType.Binary;
|
||||||
|
|
||||||
else if (type == typeof(Guid))
|
if (type == typeof(Guid))
|
||||||
return DbType.Guid;
|
return DbType.Guid;
|
||||||
|
|
||||||
else
|
return DbType.Object;
|
||||||
return DbType.Object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDbType(IDbDataParameter param, Enum dbType)
|
public void SetDbType(IDbDataParameter param, Enum dbType)
|
||||||
|
@ -26,38 +26,37 @@ public Enum GetDbType(Type type)
|
|||||||
if (type == typeof(String))
|
if (type == typeof(String))
|
||||||
return OleDbType.VarChar;
|
return OleDbType.VarChar;
|
||||||
|
|
||||||
else if (type == typeof(Int32))
|
if (type == typeof(Int32))
|
||||||
return OleDbType.Integer;
|
return OleDbType.Integer;
|
||||||
|
|
||||||
else if (type == typeof(Decimal))
|
if (type == typeof(Decimal))
|
||||||
return OleDbType.Decimal;
|
return OleDbType.Decimal;
|
||||||
|
|
||||||
else if (type == typeof(DateTime))
|
if (type == typeof(DateTime))
|
||||||
return OleDbType.DBTimeStamp;
|
return OleDbType.DBTimeStamp;
|
||||||
|
|
||||||
else if (type == typeof(Boolean))
|
if (type == typeof(Boolean))
|
||||||
return OleDbType.Boolean;
|
return OleDbType.Boolean;
|
||||||
|
|
||||||
else if (type == typeof(Int16))
|
if (type == typeof(Int16))
|
||||||
return OleDbType.SmallInt;
|
return OleDbType.SmallInt;
|
||||||
|
|
||||||
else if (type == typeof(Int64))
|
if (type == typeof(Int64))
|
||||||
return OleDbType.BigInt;
|
return OleDbType.BigInt;
|
||||||
|
|
||||||
else if (type == typeof(Double))
|
if (type == typeof(Double))
|
||||||
return OleDbType.Double;
|
return OleDbType.Double;
|
||||||
|
|
||||||
else if (type == typeof(Byte))
|
if (type == typeof(Byte))
|
||||||
return OleDbType.Binary;
|
return OleDbType.Binary;
|
||||||
|
|
||||||
else if (type == typeof(Byte[]))
|
if (type == typeof(Byte[]))
|
||||||
return OleDbType.VarBinary;
|
return OleDbType.VarBinary;
|
||||||
|
|
||||||
else if (type == typeof(Guid))
|
if (type == typeof(Guid))
|
||||||
return OleDbType.Guid;
|
return OleDbType.Guid;
|
||||||
|
|
||||||
else
|
return OleDbType.Variant;
|
||||||
return OleDbType.Variant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDbType(IDbDataParameter param, Enum dbType)
|
public void SetDbType(IDbDataParameter param, Enum dbType)
|
||||||
|
@ -26,41 +26,40 @@ public Enum GetDbType(Type type)
|
|||||||
if (type == typeof(String))
|
if (type == typeof(String))
|
||||||
return SqlDbType.VarChar;
|
return SqlDbType.VarChar;
|
||||||
|
|
||||||
else if (type == typeof(Int32))
|
if (type == typeof(Int32))
|
||||||
return SqlDbType.Int;
|
return SqlDbType.Int;
|
||||||
|
|
||||||
else if (type == typeof(Decimal))
|
if (type == typeof(Decimal))
|
||||||
return SqlDbType.Decimal;
|
return SqlDbType.Decimal;
|
||||||
|
|
||||||
else if (type == typeof(DateTime))
|
if (type == typeof(DateTime))
|
||||||
return SqlDbType.DateTime;
|
return SqlDbType.DateTime;
|
||||||
|
|
||||||
else if (type == typeof(Boolean))
|
if (type == typeof(Boolean))
|
||||||
return SqlDbType.Bit;
|
return SqlDbType.Bit;
|
||||||
|
|
||||||
else if (type == typeof(Int16))
|
if (type == typeof(Int16))
|
||||||
return SqlDbType.SmallInt;
|
return SqlDbType.SmallInt;
|
||||||
|
|
||||||
else if (type == typeof(Int64))
|
if (type == typeof(Int64))
|
||||||
return SqlDbType.BigInt;
|
return SqlDbType.BigInt;
|
||||||
|
|
||||||
else if (type == typeof(Double))
|
if (type == typeof(Double))
|
||||||
return SqlDbType.Float;
|
return SqlDbType.Float;
|
||||||
|
|
||||||
else if (type == typeof(Char))
|
if (type == typeof(Char))
|
||||||
return SqlDbType.Char;
|
return SqlDbType.Char;
|
||||||
|
|
||||||
else if (type == typeof(Byte))
|
if (type == typeof(Byte))
|
||||||
return SqlDbType.Binary;
|
return SqlDbType.Binary;
|
||||||
|
|
||||||
else if (type == typeof(Byte[]))
|
if (type == typeof(Byte[]))
|
||||||
return SqlDbType.VarBinary;
|
return SqlDbType.VarBinary;
|
||||||
|
|
||||||
else if (type == typeof(Guid))
|
if (type == typeof(Guid))
|
||||||
return SqlDbType.UniqueIdentifier;
|
return SqlDbType.UniqueIdentifier;
|
||||||
|
|
||||||
else
|
return SqlDbType.Variant;
|
||||||
return SqlDbType.Variant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDbType(IDbDataParameter param, Enum dbType)
|
public void SetDbType(IDbDataParameter param, Enum dbType)
|
||||||
|
@ -32,10 +32,7 @@ public string Generate()
|
|||||||
{
|
{
|
||||||
return ComplexPaging();
|
return ComplexPaging();
|
||||||
}
|
}
|
||||||
else
|
return SimplePaging();
|
||||||
{
|
|
||||||
return SimplePaging();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -18,10 +18,7 @@ public string Generate()
|
|||||||
{
|
{
|
||||||
return ComplexRowCount();
|
return ComplexRowCount();
|
||||||
}
|
}
|
||||||
else
|
return SimpleRowCount();
|
||||||
{
|
|
||||||
return SimpleRowCount();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -95,10 +95,7 @@ public string NameOrAltName(IColumnInfo columnInfo)
|
|||||||
{
|
{
|
||||||
return columnInfo.AltName;
|
return columnInfo.AltName;
|
||||||
}
|
}
|
||||||
else
|
return columnInfo.Name;
|
||||||
{
|
|
||||||
return columnInfo.Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildFromClause(StringBuilder sql)
|
public void BuildFromClause(StringBuilder sql)
|
||||||
|
@ -32,10 +32,7 @@ public string Generate()
|
|||||||
{
|
{
|
||||||
return ComplexPaging();
|
return ComplexPaging();
|
||||||
}
|
}
|
||||||
else
|
return SimplePaging();
|
||||||
{
|
|
||||||
return SimplePaging();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string SimplePaging()
|
private string SimplePaging()
|
||||||
|
@ -281,10 +281,7 @@ public override string ToString()
|
|||||||
{
|
{
|
||||||
return _sb.ToString();
|
return _sb.ToString();
|
||||||
}
|
}
|
||||||
else
|
return _constantWhereClause;
|
||||||
{
|
|
||||||
return _constantWhereClause;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,14 +32,11 @@ public static object GetDefaultValue(Type fieldType)
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (fieldType.IsValueType)
|
if (fieldType.IsValueType)
|
||||||
{
|
{
|
||||||
return Activator.CreateInstance(fieldType);
|
return Activator.CreateInstance(fieldType);
|
||||||
}
|
}
|
||||||
else
|
return null;
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -11,11 +11,11 @@ public static class PathExtensions
|
|||||||
private const string NZBDRONE_LOG_DB = "logs.db";
|
private const string NZBDRONE_LOG_DB = "logs.db";
|
||||||
private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
|
private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
|
||||||
private const string NLOG_CONFIG_FILE = "nlog.config";
|
private const string NLOG_CONFIG_FILE = "nlog.config";
|
||||||
|
private const string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
|
||||||
|
|
||||||
private static readonly string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update" + Path.DirectorySeparatorChar;
|
private static readonly string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update" + Path.DirectorySeparatorChar;
|
||||||
private static readonly string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone" + Path.DirectorySeparatorChar;
|
private static readonly string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone" + Path.DirectorySeparatorChar;
|
||||||
private static readonly string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup" + Path.DirectorySeparatorChar;
|
private static readonly string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup" + Path.DirectorySeparatorChar;
|
||||||
private static readonly string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
|
|
||||||
private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar;
|
private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar;
|
||||||
private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + Path.DirectorySeparatorChar;
|
private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
|
@ -118,12 +118,9 @@ public string GetSeriesPath(XbmcSettings settings, Series series)
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
var matchingSeries = allSeries.FirstOrDefault(s => s.ImdbNumber == series.TvdbId || s.Label == series.Title);
|
||||||
{
|
|
||||||
var matchingSeries = allSeries.FirstOrDefault(s => s.ImdbNumber == series.TvdbId || s.Label == series.Title);
|
|
||||||
|
|
||||||
if (matchingSeries != null) return matchingSeries.File;
|
if (matchingSeries != null) return matchingSeries.File;
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user