< Summary

Information
Class: Fluorite.Strainer.Services.Metadata.Attributes.PropertyMetadataDictionaryProvider
Assembly: Fluorite.Strainer
File(s): /builds/fluorite/strainer/src/Strainer/Services/Metadata/Attributes/PropertyMetadataDictionaryProvider.cs
Line coverage
38%
Covered lines: 8
Uncovered lines: 13
Coverable lines: 21
Total lines: 45
Line coverage: 38%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetMetadata(...)100%210%
GetMetadata(...)100%210%

File(s)

/builds/fluorite/strainer/src/Strainer/Services/Metadata/Attributes/PropertyMetadataDictionaryProvider.cs

#LineLine coverage
 1using Fluorite.Extensions;
 2using Fluorite.Strainer.Attributes;
 3using Fluorite.Strainer.Models.Metadata;
 4
 5namespace Fluorite.Strainer.Services.Metadata.Attributes;
 6
 7public class PropertyMetadataDictionaryProvider : IPropertyMetadataDictionaryProvider
 8{
 9    private readonly IPropertyInfoProvider _propertyInfoProvider;
 10    private readonly IStrainerAttributeProvider _strainerAttributeProvider;
 11    private readonly IAttributePropertyMetadataBuilder _attributePropertyMetadataBuilder;
 12
 813    public PropertyMetadataDictionaryProvider(
 814        IPropertyInfoProvider propertyInfoProvider,
 815        IStrainerAttributeProvider strainerAttributeProvider,
 816        IAttributePropertyMetadataBuilder attributePropertyMetadataBuilder)
 17    {
 818        _propertyInfoProvider = Guard.Against.Null(propertyInfoProvider);
 819        _strainerAttributeProvider = Guard.Against.Null(strainerAttributeProvider);
 820        _attributePropertyMetadataBuilder = Guard.Against.Null(attributePropertyMetadataBuilder);
 821    }
 22
 23    public IReadOnlyDictionary<string, IPropertyMetadata> GetMetadata(Type type)
 24    {
 025        Guard.Against.Null(type);
 26
 027        return _propertyInfoProvider.GetPropertyInfos(type)
 028            .Select(propertyInfo => _strainerAttributeProvider.GetPropertyAttribute(propertyInfo))
 029            .Where(attribute => attribute is not null)
 030            .Select(attribute => attribute!)
 031            .ToDictionary(attribute => attribute.Name, attribute => (IPropertyMetadata)attribute)
 032            .ToReadOnly();
 33    }
 34
 35    public IReadOnlyDictionary<string, IPropertyMetadata> GetMetadata(Type type, StrainerObjectAttribute strainerObjectA
 36    {
 037        Guard.Against.Null(type);
 038        Guard.Against.Null(strainerObjectAttribute);
 39
 040        return _propertyInfoProvider.GetPropertyInfos(type)
 041            .Select(propertyInfo => _attributePropertyMetadataBuilder.BuildDefaultMetadataForProperty(strainerObjectAttr
 042            .ToDictionary(metadata => metadata.Name, metadata => metadata)
 043            .ToReadOnly();
 44    }
 45}