< Summary

Information
Class: ValidateLib.Metadata.Descriptors.Descriptor
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\Descriptor.cs
Line coverage
46%
Covered lines: 13
Uncovered lines: 15
Coverable lines: 28
Total lines: 76
Line coverage: 46.4%
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\Descriptor.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;
 9
 10namespace ValidateLib.Metadata.Descriptors
 11{
 12    /// <summary>
 13    /// Base class for all descriptors.
 14    /// Contains properties all descriptors must containt.
 15    /// </summary>
 16    public class Descriptor : DescriptorBase, Interfaces.IParsable<Descriptor>, ITypable
 17    {
 18
 19        public LinkProperty? id;
 20        public AtomicPropertyString? type;
 021        public static string getTypeForTypeProperty() => "undefined";
 22        static public void MergeTwoList<T>(List<T> toList, List<T> fromList)
 23        {
 124            toList.AddRange(fromList);
 25
 126        }
 27        static protected List<Warning> NormalizeProperty(JProperty property, Context context)
 28        {
 129            List<Warning> errors = new List<Warning>();
 130            switch (property.Name)
 31            {
 32                case "@id":
 133                    if (property.Value.Type == JTokenType.String && property.Value.ToString().StartsWith("_:")) return e
 134                    return LinkProperty.Normalize(property.Value, context, property);
 35                case "@type":
 136                    return errors;
 37                default:
 138                    return errors;
 39
 40            }
 41        }
 42        public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings)
 43        {
 144            string propertyName = property.Name;
 145            if (CommonProperty.IsCommonProperty(propertyName))
 146                return ((CommonPropertiesDescriptor)this).GetPropertyParser(property, warnings);
 47            switch (propertyName)
 48            {
 49                case "@id":
 150                    return new IdPropertyParser(warnings, this);
 51                case "@type":
 052                    if (this is TableGroupDescriptor)
 053                        return new TypePropertyParser<TableGroupDescriptor>(warnings, this);
 054                    else if (this is TableDescriptor)
 055                        return new TypePropertyParser<TableDescriptor>(warnings, this);
 056                    else if (this is ColumnDescriptor)
 057                        return new TypePropertyParser<ColumnDescriptor>(warnings, this);
 058                    else if (this is DialectDescriptor)
 059                        return new TypePropertyParser<DialectDescriptor>(warnings, this);
 060                    else if (this is TransformationDescriptor)
 061                        return new TypePropertyParser<TransformationDescriptor>(warnings, this);
 062                    else if (this is DatatypeDescriptor)
 063                        return new TypePropertyParser<DatatypeDescriptor>(warnings, this);
 064                    else return new TypePropertyParser<Descriptor>(warnings, this);
 65                default:
 166                    return null;
 67
 68            }
 69        }
 70
 71        public static IParser<Descriptor> GetParser(List<Warning> warnings, Descriptor? descriptor = null)
 72        {
 073            throw new NotImplementedException();
 74        }
 75    }
 76}