< Summary

Information
Class: ValidateLib.Metadata.Properties.ArrayProperty<T>
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Properties\ArrayProperty.cs
Line coverage
62%
Covered lines: 10
Uncovered lines: 6
Coverable lines: 16
Total lines: 49
Line coverage: 62.5%
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

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Properties\ArrayProperty.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors;
 4using ValidateLib.Metadata.Descriptors.Interfaces;
 5
 6namespace ValidateLib.Metadata.Properties
 7{
 8    public class ArrayProperty<T> : Property<List<T>>, INormalize
 9    {
 110        public ArrayProperty(List<T> value) : base(value)
 11        {
 12
 113        }
 14
 15        public void AddItem(T item)
 16        {
 117            if (_value is null) _value = new List<T>();
 118            _value.Add(item);
 119        }
 20
 21
 22        public static ArrayProperty<string> CreateStringArrayPropertyFromJToken(JToken token)
 23        {
 024            List<string> list = new List<string>();
 025            if (token.Type != JTokenType.Array) throw new ArgumentException();
 026            foreach (var item in token)
 27            {
 028                list.Add(item.ToString());
 29            }
 030            return new ArrayProperty<string>(list);
 31        }
 32
 33        public static List<Warning> Normalize<T2>(JToken token, Context context, JProperty? property = null) where T2 : 
 34        {
 135            List<Warning> errors = new List<Warning>();
 136            if (token.Type != JTokenType.Array) return errors;
 137            foreach (var item in (JArray)token)
 38            {
 139                var results = T2.Normalize(item, context, property);
 40            }
 141            return errors;
 42        }
 43        static List<Warning> INormalize.Normalize(JToken token, Context context, JProperty? prop)
 44        {
 045            throw new NotImplementedException();
 46        }
 47
 48    }
 49}