mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-26 20:11:49 +02:00
schema updates
This commit is contained in:
@@ -8,38 +8,6 @@ namespace NzbDrone.Api.ClientSchema
|
||||
{
|
||||
public static class SchemaDeserializer
|
||||
{
|
||||
public static T DeserializeSchema<T>(T model, List<Field> fields)
|
||||
{
|
||||
var properties = model.GetType().GetSimpleProperties();
|
||||
|
||||
foreach (var propertyInfo in properties)
|
||||
{
|
||||
var fieldAttribute = propertyInfo.GetAttribute<FieldDefinitionAttribute>(false);
|
||||
|
||||
if (fieldAttribute != null)
|
||||
{
|
||||
var field = fields.Find(f => f.Name == propertyInfo.Name);
|
||||
|
||||
if (propertyInfo.PropertyType == typeof (Int32))
|
||||
{
|
||||
var intValue = Convert.ToInt32(field.Value);
|
||||
propertyInfo.SetValue(model, intValue, null);
|
||||
}
|
||||
|
||||
else if (propertyInfo.PropertyType == typeof(Nullable<Int32>))
|
||||
{
|
||||
var intValue = field.Value.ToString().ParseInt32();
|
||||
propertyInfo.SetValue(model, intValue, null);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
propertyInfo.SetValue(model, field.Value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user