< Summary

Information
Class: ValidateLib.Metadata.Parsers.ArrayPropertyParser<T>
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Parsers\ArrayPropertyParser.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 40
Line coverage: 100%
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

MethodBlocks covered Blocks not covered
ArrayPropertyParser(...)61
ParseJToken(...)320

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Parsers\ArrayPropertyParser.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors;
 4using ValidateLib.Metadata.Properties;
 5
 6namespace ValidateLib.Metadata.Parsers
 7{
 8    public class ArrayPropertyParser<T> where T : DescriptorBase, Descriptors.Interfaces.IParsable<T>
 9    {
 110        public ArrayProperty<T> Value { get; set; } = new ArrayProperty<T>(new List<T>());
 111        public List<Warning> Warnings { get; set; }
 12
 113        public ArrayPropertyParser(List<Warning> warnings, ArrayProperty<T>? descriptor = null)
 14        {
 115            if (descriptor != null) Value = descriptor;
 116            Warnings = warnings;
 117        }
 18        public ArrayProperty<T> ParseJToken(JProperty property)
 19        {
 120            if (property.Value.Type != JTokenType.Array)
 21            {
 122                Warnings.Add(WarningFactory.GetArrayPropertyWrongValueWarning(property, property.Value.Type.ToString()))
 123                return Value;
 24            }
 25            else
 26            {
 27
 128                foreach (var item in (JArray)property.Value)
 29                {
 130                    var TParser = T.GetParser(Warnings);
 131                    var TObject = TParser.ParseJToken(item, property.Name);
 132                    if (!TObject.IsInvalid) Value.AddItem(TObject);
 33
 34                }
 35
 136                return Value;
 37            }
 38        }
 39    }
 40}