< Summary

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

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\ColumnDescriptor.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors.Interfaces;
 4using ValidateLib.Metadata.Parsers;
 5using ValidateLib.Metadata.Properties;
 6using ValidateLib.Metadata.Properties.AtomicProperties;
 7using ValidateLib.Metadata.PropertyParsers;
 8using ValidateLib.Metadata.PropertyParsers.Column;
 9using ValidateLib.Metadata.PropertyParsers.DescriptorNS;
 10
 11namespace ValidateLib.Metadata.Descriptors
 12{
 13    public class ColumnDescriptor : InheritedPropertiesDescriptor, INormalize, Interfaces.IParsable<ColumnDescriptor>, I
 14    {
 115        public AtomicPropertyString? name { get; set; }
 116        public AtomicPropertyBoolean? suppresOutput { get; set; } = new AtomicPropertyBoolean(false);
 117        public NaturalLanguageProperty? titles { get; set; }
 118        public AtomicPropertyBoolean? _virtual { get; set; } = new AtomicPropertyBoolean(false);
 119        new public static string getTypeForTypeProperty() => "Column";
 20        public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null)
 21        {
 122            List<Warning> errors = new List<Warning>();
 123            if (token.Type != JTokenType.Object) return new List<Warning> { WarningFactory.GetObjectPropertyWrongValueWa
 124            foreach (JProperty jProperty in token)
 25            {
 126                var results = NormalizeProperty(jProperty, context);
 127                MergeTwoList(errors, results);
 28            }
 129            return errors;
 30        }
 31
 32        new static protected List<Warning> NormalizeProperty(JProperty property, Context context)
 33        {
 134            List<Warning> errors = new List<Warning>();
 135            if (CommonProperty.IsCommonProperty(property.Name)) CommonProperty.Normalize(property.Value, context, proper
 136            switch (property.Name)
 37            {
 38                case "name":
 39                case "suppresOutput":
 40                case "virtual":
 141                    return errors;
 42                case "titles":
 143                    return NaturalLanguageProperty.Normalize(property.Value, context, property);
 44                default:
 145                    return InheritedPropertiesDescriptor.NormalizeProperty(property, context);
 46
 47            }
 48        }
 49
 150        public static IParser<ColumnDescriptor> GetParser(List<Warning> warnings, ColumnDescriptor? descriptor = null) =
 51        new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings)
 52        {
 153            string propertyName = property.Name;
 154            if (CommonProperty.IsCommonProperty(propertyName))
 55            {
 156                ((CommonPropertiesDescriptor)this).GetPropertyParser(property, warnings);
 57            }
 58            switch (propertyName)
 59            {
 60                case "name":
 161                    return new NamePropertyParser(warnings, this);
 62                case "suppressOutput":
 163                    return new SuppresOutputPropertyParser(warnings, this);
 64                case "titles":
 165                    return new TitlesPropertyParser(warnings, this);
 66                case "virtual":
 167                    return new VirtualPropertyParser(warnings, this);
 68                case "@type":
 169                    return new TypePropertyParser<ColumnDescriptor>(warnings, this);
 70                default:
 171                    return ((InheritedPropertiesDescriptor)this).GetPropertyParser(property, warnings);
 72            }
 73        }
 74    }
 75
 76
 77}