| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | 3 | | using ValidateLib.Metadata.Parsers; |
| | 4 | | using ValidateLib.Metadata.Properties; |
| | 5 | | using ValidateLib.Metadata.Properties.AtomicProperties; |
| | 6 | | using ValidateLib.Metadata.PropertyParsers; |
| | 7 | | using ValidateLib.Metadata.PropertyParsers.InheritedProperties; |
| | 8 | |
|
| | 9 | | namespace ValidateLib.Metadata.Descriptors |
| | 10 | | { |
| | 11 | | public class InheritedPropertiesDescriptor : CommonPropertiesDescriptor, Interfaces.IParsable<InheritedPropertiesDes |
| | 12 | | { |
| 1 | 13 | | public URITemplateProperty? aboutURL { get; set; } |
| 1 | 14 | | public AtomicProperty<DatatypeDescriptor>? datatype { get; set; } |
| 1 | 15 | | public AtomicPropertyString? _default { get; set; } = new AtomicPropertyString("") { IsDefault = true }; |
| 1 | 16 | | public AtomicPropertyString? lang { get; set; } = new AtomicPropertyString("und") { IsDefault = true }; |
| 1 | 17 | | public AtomicPropertyArray<string>? _null { get; set; } = new AtomicPropertyArray<string>(new List<string>() { " |
| 1 | 18 | | public AtomicPropertyBoolean? ordered { get; set; } = new AtomicPropertyBoolean(false) { IsDefault = true }; |
| 1 | 19 | | public URITemplateProperty? propertyUrl { get; set; } |
| 1 | 20 | | public AtomicPropertyBoolean? required { get; set; } = new AtomicPropertyBoolean(false) { IsDefault = true }; |
| 1 | 21 | | public AtomicPropertyString? separator { get; set; } = new AtomicPropertyString(null) { IsDefault = true }; |
| 1 | 22 | | public AtomicPropertyString? textDirection { get; set; } = new AtomicPropertyString("inherit") { IsDefault = tru |
| 1 | 23 | | public URITemplateProperty? valueUrl { get; set; } |
| | 24 | |
|
| | 25 | | new public static List<Warning> NormalizeProperty(JProperty property, Context context) |
| | 26 | | { |
| 1 | 27 | | List<Warning> errors = new List<Warning>(); |
| 1 | 28 | | if (CommonProperty.IsCommonProperty(property.Name)) return CommonProperty.Normalize(property.Value, context, |
| 1 | 29 | | switch (property.Name) |
| | 30 | | { |
| | 31 | | case "aboutUrl": |
| | 32 | | case "default": |
| | 33 | | case "lang": |
| | 34 | | case "null": |
| | 35 | | case "ordered": |
| | 36 | | case "propertyUrl": |
| | 37 | | case "required": |
| | 38 | | case "separator": |
| | 39 | | case "textDirection": |
| | 40 | | case "valueUrl": |
| 1 | 41 | | return errors; |
| | 42 | | case "datatype": |
| 1 | 43 | | return DatatypeDescriptor.Normalize(property.Value, context, property); |
| | 44 | | default: |
| 1 | 45 | | return ContextDescriptor.NormalizeProperty(property, context); |
| | 46 | |
|
| | 47 | | } |
| | 48 | | } |
| | 49 | |
|
| | 50 | | new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings) |
| | 51 | | { |
| 1 | 52 | | string propertyName = property.Name; |
| 1 | 53 | | if (CommonProperty.IsCommonProperty(propertyName)) |
| | 54 | | { |
| 1 | 55 | | ((CommonPropertiesDescriptor)this).GetPropertyParser(property, warnings); |
| | 56 | | } |
| | 57 | | switch (propertyName) |
| | 58 | | { |
| | 59 | | case "aboutUrl": |
| 1 | 60 | | return new AboutUrlPropertyParser(warnings, this); |
| | 61 | | case "datatype": |
| 1 | 62 | | return new DatatypePropertyParser(warnings, this); |
| | 63 | | case "default": |
| 1 | 64 | | return new DefaultPropertyParser(warnings, this); |
| | 65 | | case "lang": |
| 1 | 66 | | return new LangPropertyParser(warnings, this); |
| | 67 | | case "null": |
| 1 | 68 | | return new NullPropertyParser(warnings, this); |
| | 69 | | case "ordered": |
| 1 | 70 | | return new OrderedPropertyParser(warnings, this); |
| | 71 | | case "propertyUrl": |
| 1 | 72 | | return new PropertyUrlPropertyParser(warnings, this); |
| | 73 | | case "required": |
| 1 | 74 | | return new RequiredPropertyParser(warnings, this); |
| | 75 | | case "separator": |
| 1 | 76 | | return new SeparatorPropertyParser(warnings, this); |
| | 77 | | case "textDirection": |
| 1 | 78 | | return new TextDirectionPropertyParser(warnings, this); |
| | 79 | | case "valueUrl": |
| 1 | 80 | | return new ValueUrlPropertyParser(warnings, this); |
| | 81 | | default: |
| 1 | 82 | | return ((ContextDescriptor)this).GetPropertyParser(property, warnings); |
| | 83 | | } |
| | 84 | | } |
| | 85 | |
|
| | 86 | | public static IParser<InheritedPropertiesDescriptor> GetParser(List<Warning> warnings, InheritedPropertiesDescri |
| | 87 | | { |
| 0 | 88 | | throw new NotImplementedException(); |
| | 89 | | } |
| | 90 | |
|
| | 91 | | public virtual void ProcessPassedInheritedProperties(InheritedPropertiesDescriptor descriptor) |
| | 92 | | { |
| 1 | 93 | | if ((aboutURL is null || aboutURL.IsDefault) && descriptor.aboutURL is not null) aboutURL = descriptor.about |
| 1 | 94 | | if ((datatype is null || datatype.IsDefault) && descriptor.datatype is not null) datatype = descriptor.datat |
| 1 | 95 | | if ((_default is null || _default.IsDefault) && descriptor._default is not null) _default = descriptor._defa |
| 1 | 96 | | if ((lang is null || lang.IsDefault) && descriptor.lang is not null) lang = descriptor.lang; |
| 1 | 97 | | if ((_null is null || _null.IsDefault) && descriptor._null is not null) _null = descriptor._null; |
| 1 | 98 | | if ((ordered is null || ordered.IsDefault) && descriptor.ordered is not null) ordered = descriptor.ordered; |
| 1 | 99 | | if ((propertyUrl is null || propertyUrl.IsDefault) && descriptor.propertyUrl is not null) propertyUrl = desc |
| 1 | 100 | | if ((required is null || required.IsDefault) && descriptor.required is not null) required = descriptor.requi |
| 1 | 101 | | if ((separator is null || separator.IsDefault) && descriptor.separator is not null) separator = descriptor.s |
| 1 | 102 | | if ((textDirection is null || textDirection.IsDefault) && descriptor.textDirection is not null) textDirectio |
| 1 | 103 | | if ((valueUrl is null || valueUrl.IsDefault) && descriptor.valueUrl is not null) valueUrl = descriptor.value |
| | 104 | |
|
| 1 | 105 | | PassInheritedProperties(); |
| | 106 | |
|
| 1 | 107 | | } |
| | 108 | |
|
| | 109 | | public virtual void PassInheritedProperties() |
| | 110 | | { |
| 1 | 111 | | } |
| | 112 | | } |
| | 113 | | } |