|
|
|
|
@ -12,16 +12,25 @@ using System.Threading.Tasks; |
|
|
|
|
using System.Xml.Linq; |
|
|
|
|
using GBase.DataHandling.Exceptions; |
|
|
|
|
using GBase.Helpers; |
|
|
|
|
using GBase.Interfaces; |
|
|
|
|
using GBase.Interfaces.DataHandling; |
|
|
|
|
using GBase.Interfaces.DataHandling.Xml; |
|
|
|
|
|
|
|
|
|
namespace GBase.DataHandling |
|
|
|
|
{ |
|
|
|
|
/// <summary> |
|
|
|
|
/// A <see cref="IDataReader"/> that reads from a xml file |
|
|
|
|
/// An <see cref="IDataReader"/> that reads from a xml file |
|
|
|
|
/// </summary> |
|
|
|
|
public class XmlDataReader : IXmlDataReader |
|
|
|
|
{ |
|
|
|
|
private readonly IGBase _gBase; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// An <see cref="IDataReader"/> that reads from a xml file |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="gBase">The <see cref="IGBase"/></param> |
|
|
|
|
public XmlDataReader(IGBase gBase) => _gBase = gBase; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Read the data of a property |
|
|
|
|
/// </summary> |
|
|
|
|
@ -66,7 +75,7 @@ namespace GBase.DataHandling |
|
|
|
|
IEnumerable<string> values = valueElements.Select(v => v.Value); |
|
|
|
|
|
|
|
|
|
if (typeof(TProperty) != typeof(string) && typeof(TProperty).GetInterfaces().Contains(typeof(IEnumerable))) //read property is an IEnumerable |
|
|
|
|
return values.Select(Enumerables.ConvertToGBaseEnumerable<TProperty>).ToList(); |
|
|
|
|
return values.Select(s => Enumerables.ConvertToGBaseEnumerable<TProperty>(s, _gBase)).ToList(); |
|
|
|
|
|
|
|
|
|
return values.Select(value => (TProperty) Convert.ChangeType(value, typeof(TProperty))).ToList(); |
|
|
|
|
}, cancellationToken); |
|
|
|
|
|