mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Able to create new Newznab indexers
This commit is contained in:
parent
5660b5086c
commit
e4410d8cb7
8 changed files with 117 additions and 13 deletions
27
NzbDrone.Api/ClientSchema/SchemaDeserializer.cs
Normal file
27
NzbDrone.Api/ClientSchema/SchemaDeserializer.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System.Collections.Generic;
|
||||
using NzbDrone.Common.Reflection;
|
||||
using NzbDrone.Core.Annotations;
|
||||
|
||||
namespace NzbDrone.Api.ClientSchema
|
||||
{
|
||||
public static class SchemaDeserializer
|
||||
{
|
||||
public static object DeserializeSchema(object 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);
|
||||
propertyInfo.SetValue(model, field.Value, null);
|
||||
}
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue