< Summary

Information
Class: Fluorite.Strainer.Services.Metadata.Attributes.StrainerAttributeProvider
Assembly: Fluorite.Strainer
File(s): /builds/fluorite/strainer/src/Strainer/Services/Metadata/Attributes/StrainerAttributeProvider.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 40
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetObjectAttribute(...)100%22100%
GetPropertyAttribute(...)100%22100%

File(s)

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

#LineLine coverage
 1using Fluorite.Strainer.Attributes;
 2using System.Reflection;
 3
 4namespace Fluorite.Strainer.Services.Metadata.Attributes;
 5
 6public class StrainerAttributeProvider : IStrainerAttributeProvider
 7{
 8    private readonly IPropertyInfoProvider _propertyInfoProvider;
 9
 1410    public StrainerAttributeProvider(IPropertyInfoProvider propertyInfoProvider)
 11    {
 1412        _propertyInfoProvider = Guard.Against.Null(propertyInfoProvider);
 1413    }
 14
 15    public StrainerObjectAttribute? GetObjectAttribute(Type type)
 16    {
 317        Guard.Against.Null(type);
 18
 219        var attribute = type.GetCustomAttribute<StrainerObjectAttribute>(inherit: false);
 220        if (attribute != null)
 21        {
 122            attribute.DefaultSortingPropertyInfo = _propertyInfoProvider.GetPropertyInfo(type, attribute.DefaultSortingP
 23        }
 24
 225        return attribute;
 26    }
 27
 28    public StrainerPropertyAttribute? GetPropertyAttribute(PropertyInfo propertyInfo)
 29    {
 330        Guard.Against.Null(propertyInfo);
 31
 232        var attribute = propertyInfo.GetCustomAttribute<StrainerPropertyAttribute>(inherit: false);
 233        if (attribute != null)
 34        {
 135            attribute.PropertyInfo = propertyInfo;
 36        }
 37
 238        return attribute;
 39    }
 40}