|
|
|
|
@ -4,7 +4,9 @@ |
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Threading; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
using GBase.DataHandling.Cache.Factories; |
|
|
|
|
using GBase.Interfaces.DataHandling.Cache; |
|
|
|
|
@ -103,9 +105,11 @@ namespace GBase.DataHandling.Cache |
|
|
|
|
/// </summary> |
|
|
|
|
/// <typeparam name="T">The <see cref="Type"/> that implements the property</typeparam> |
|
|
|
|
/// <typeparam name="TProperty">The <see cref="Type"/> of the property</typeparam> |
|
|
|
|
/// <param name="file"></param> |
|
|
|
|
/// <param name="propertyName">The name of the property</param> |
|
|
|
|
/// <param name="cancellationToken"></param> |
|
|
|
|
/// <returns>An <see cref="IEnumerable{T}"/> with all the values for the property</returns> |
|
|
|
|
public async Task<IEnumerable<TProperty>> TryGetValues<T, TProperty>(string propertyName) |
|
|
|
|
public async Task<IEnumerable<TProperty>> TryGetValues<T, TProperty>(FileStream file, string propertyName, CancellationToken cancellationToken) |
|
|
|
|
{ |
|
|
|
|
IXmlDataHandlerCacheEntry entry = _cache.FirstOrDefault(e => e.Type == typeof(T)); |
|
|
|
|
IDataHandlerCachePropertyEntry property = entry?.Properties.FirstOrDefault(p => p.PropertyName.Equals(propertyName)); |
|
|
|
|
@ -114,7 +118,7 @@ namespace GBase.DataHandling.Cache |
|
|
|
|
|
|
|
|
|
if (!property.IsInitialized) //initialize property by reading the values from the xml |
|
|
|
|
{ |
|
|
|
|
List<TProperty> values = (await _xmlDataReader.Read<T, TProperty>(propertyName))?.ToList(); |
|
|
|
|
List<TProperty> values = (await _xmlDataReader.Read<T, TProperty>(file, propertyName, cancellationToken))?.ToList(); |
|
|
|
|
if (values != null) |
|
|
|
|
{ |
|
|
|
|
foreach (TProperty value in values.Where(value => !property.Values.Any(v => v.Equals(value)))) |
|
|
|
|
|