| | | 1 | | using Newtonsoft.Json.Linq; |
| | | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | | 3 | | using ValidateLib.Metadata.Descriptors; |
| | | 4 | | using ValidateLib.UtilityClasses; |
| | | 5 | | |
| | | 6 | | namespace ValidateLib.Metadata.PropertyParsers.DIalect |
| | | 7 | | { |
| | | 8 | | internal class EncodingPropertyParser : PropertyParserBase<DialectDescriptor>, IPropertyParser<DialectDescriptor> |
| | | 9 | | { |
| | 1 | 10 | | public EncodingPropertyParser(List<Warning> warnings, DialectDescriptor descriptor) : base(warnings, descriptor) |
| | | 11 | | { |
| | 1 | 12 | | } |
| | | 13 | | |
| | | 14 | | public void ParseProperty(JProperty property) |
| | | 15 | | { |
| | 1 | 16 | | if (property.Value.Type != JTokenType.String) |
| | | 17 | | { |
| | 0 | 18 | | Warnings.Add(WarningFactory.GetInvalidEncodingValueWarning(property.Value.ToString())); |
| | 0 | 19 | | Descriptor.encoding = new Properties.AtomicProperties.AtomicPropertyString("utf-8"); |
| | | 20 | | } |
| | | 21 | | else |
| | | 22 | | { |
| | 1 | 23 | | if (!EncodingUtilityClass.IsValidEncodingName(property.Value.ToString())) |
| | | 24 | | { |
| | 1 | 25 | | Warnings.Add(WarningFactory.GetInvalidEncodingValueWarning(property.Value.ToString())); |
| | 1 | 26 | | Descriptor.encoding = new Properties.AtomicProperties.AtomicPropertyString("utf-8"); |
| | | 27 | | } |
| | | 28 | | else |
| | | 29 | | { |
| | 1 | 30 | | Descriptor.encoding = new Properties.AtomicProperties.AtomicPropertyString(property.Value.ToString() |
| | | 31 | | } |
| | | 32 | | } |
| | 1 | 33 | | } |
| | | 34 | | } |
| | | 35 | | } |