< Summary

Information
Class: ValidateLib.Metadata.Descriptors.DialectDescriptor
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\DialectDescriptor.cs
Line coverage
95%
Covered lines: 41
Uncovered lines: 2
Coverable lines: 43
Total lines: 110
Line coverage: 95.3%
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\DialectDescriptor.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.DescriptorNS;
 9using ValidateLib.Metadata.PropertyParsers.DIalect;
 10
 11namespace ValidateLib.Metadata.Descriptors
 12{
 13    public class DialectDescriptor : Descriptor, INormalize, Interfaces.IParsable<DialectDescriptor>, ITypable
 14    {
 115        public AtomicPropertyString? commentPrefix { get; set; } = null;
 116        public AtomicPropertyString? delimiter { get; set; } = new AtomicPropertyString(",") { IsDefault = true };
 117        public AtomicPropertyBoolean? doubleQuote { get; set; } = new AtomicPropertyBoolean(true) { IsDefault = true };
 118        public AtomicPropertyString? encoding { get; set; } = new AtomicPropertyString("utf-8") { IsDefault = true };
 119        public AtomicPropertyBoolean? header { get; set; } = new AtomicPropertyBoolean(true) { IsDefault = true };
 120        public AtomicPropertyInteger? headerRowCount { get; set; } = new AtomicPropertyInteger(1) { IsDefault = true };
 121        public AtomicPropertyArray<string>? lineTerminators { get; set; } = new AtomicPropertyArray<string>(new List<str
 122        public AtomicPropertyString? quoteChar { get; set; } = new AtomicPropertyString("\"") { IsDefault = true };
 123        public AtomicPropertyBoolean? skipBlankRows { get; set; } = new AtomicPropertyBoolean(false) { IsDefault = true 
 124        public AtomicPropertyBoolean? skipInitialSpace { get; set; } = new AtomicPropertyBoolean(false) { IsDefault = tr
 125        public AtomicPropertyInteger? skipColumns { get; set; } = new AtomicPropertyInteger(0) { IsDefault = true };
 126        public AtomicPropertyInteger? skipRows { get; set; } = new AtomicPropertyInteger(0) { IsDefault = true };
 127        public AtomicPropertyString? trim { get; set; } = new AtomicPropertyString("true") { IsDefault = true };
 028        public string? referenceUrl { get; set; }
 29
 130        new public static string getTypeForTypeProperty() => "Dialect";
 31
 32        public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null)
 33        {
 134            List<Warning> errors = new List<Warning>();
 135            if (token.Type != JTokenType.Object) return errors;
 136            foreach (JProperty jProperty in token)
 37            {
 138                var results = NormalizeProperty(jProperty, context);
 139                MergeTwoList(errors, results);
 40            }
 141            return errors;
 42        }
 43
 44        new static public List<Warning> NormalizeProperty(JProperty property, Context context)
 45        {
 146            List<Warning> errors = new List<Warning>();
 147            if (CommonProperty.IsCommonProperty(property.Name)) return CommonProperty.Normalize(property.Value, context,
 148            switch (property.Name)
 49            {
 50                case "commentPrefix":
 51                case "delimiter":
 52                case "doubleQuote":
 53                case "encoding":
 54                case "header":
 55                case "headerRowCount":
 56                case "lineTerminators":
 57                case "quoteChar":
 58                case "skipBlankRows":
 59                case "skipInitialSpace":
 60                case "skipColumns":
 61                case "skipRows":
 62                case "trim":
 163                    return errors;
 64                default:
 165                    return Descriptor.NormalizeProperty(property, context);
 66            }
 67        }
 68
 69        new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings)
 70        {
 171            switch (property.Name)
 72            {
 73                case "commentPrefix":
 174                    return new CommentPrefixPropertyParser(warnings, this);
 75                case "delimiter":
 176                    return new DelimiterPropertyParser(warnings, this);
 77                case "doubleQuote":
 178                    return new DoubleQuotePropertyParser(warnings, this);
 79                case "encoding":
 180                    return new EncodingPropertyParser(warnings, this);
 81                case "header":
 182                    return new HeaderPropertyParser(warnings, this);
 83                case "headerRowCount":
 184                    return new HeaderRowCountPropertyParser(warnings, this);
 85                case "lineTerminators":
 186                    return new LineTerminatorsPropertyParser(warnings, this);
 87                case "quoteChar":
 188                    return new QuoteCharPropertyParser(warnings, this);
 89                case "skipBlankRows":
 190                    return new SkipBlankRowsPropertyParser(warnings, this);
 91                case "skipInitialSpace":
 192                    return new SkipInitialSpacePropertyParser(warnings, this);
 93                case "skipColumns":
 194                    return new SkipColumnsPropertyParser(warnings, this);
 95                case "skipRows":
 196                    return new SkipRowsPropertyParser(warnings, this);
 97                case "trim":
 198                    return new TrimPropertyParser(warnings, this);
 99                case "@type":
 1100                    return new TypePropertyParser<DialectDescriptor>(warnings, this);
 101                default:
 1102                    return ((Descriptor)this).GetPropertyParser(property, warnings);
 103            }
 104        }
 105
 0106        public static IParser<DialectDescriptor> GetParser(List<Warning> warnings, DialectDescriptor? descriptor = null)
 107
 108
 109    }
 110}

Methods/Properties

commentPrefix()
commentPrefix(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
delimiter()
delimiter(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
DialectDescriptor()
doubleQuote()
doubleQuote(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyBoolean)
encoding()
encoding(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
header()
header(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyBoolean)
headerRowCount()
headerRowCount(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyInteger)
lineTerminators()
lineTerminators(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyArray<string>)
quoteChar()
quoteChar(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
skipBlankRows()
skipBlankRows(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyBoolean)
skipInitialSpace()
skipInitialSpace(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyBoolean)
skipColumns()
skipColumns(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyInteger)
skipRows()
skipRows(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyInteger)
trim()
trim(ValidateLib.Metadata.Properties.AtomicProperties.AtomicPropertyString)
referenceUrl()
referenceUrl(string)
getTypeForTypeProperty()
Normalize(Newtonsoft.Json.Linq.JToken, ValidateLib.Metadata.Descriptors.Context, Newtonsoft.Json.Linq.JProperty)
NormalizeProperty(Newtonsoft.Json.Linq.JProperty, ValidateLib.Metadata.Descriptors.Context)
GetPropertyParser(Newtonsoft.Json.Linq.JProperty, System.Collections.Generic.List<ValidateLib.ErrorsAndWarnings.Warnings.Warning>)
GetParser(System.Collections.Generic.List<ValidateLib.ErrorsAndWarnings.Warnings.Warning>, ValidateLib.Metadata.Descriptors.DialectDescriptor)