| | 1 | | using Newtonsoft.Json.Linq; |
| | 2 | | using ValidateLib.ErrorsAndWarnings.Warnings; |
| | 3 | | using ValidateLib.Metadata.Descriptors; |
| | 4 | | using ValidateLib.Metadata.Properties; |
| | 5 | | using ValidateLib.UtilityClasses; |
| | 6 | |
|
| | 7 | | namespace ValidateLib.Metadata.PropertyParsers.Transformation |
| | 8 | | { |
| | 9 | | internal class TitlesPropertyParser : PropertyParserBase<TransformationDescriptor>, IPropertyParser<TransformationDe |
| | 10 | | { |
| 1 | 11 | | public TitlesPropertyParser(List<Warning> warnings, TransformationDescriptor descriptor) : base(warnings, descri |
| | 12 | | { |
| 1 | 13 | | } |
| | 14 | |
|
| | 15 | | public void ParseProperty(JProperty property) |
| | 16 | | { |
| 1 | 17 | | if (property.Value.Type != JTokenType.Object) |
| | 18 | | { |
| 0 | 19 | | Warnings.Add(WarningFactory.GetObjectStringNormalizationProblemWarning(property.Value.ToString(), proper |
| | 20 | | } |
| | 21 | | else |
| | 22 | | { |
| 1 | 23 | | var objectValue = (JObject)property.Value; |
| 1 | 24 | | var titlesMap = new Dictionary<string, string[]>(); |
| 1 | 25 | | foreach (var jproperty in objectValue.Properties()) |
| | 26 | | { |
| 1 | 27 | | if (jproperty.Value.Type != JTokenType.Array) |
| | 28 | | { |
| 0 | 29 | | Warnings.Add(WarningFactory.GetNaturalLanguageWrongValue(jproperty.Value, jproperty.Name)); |
| 0 | 30 | | return; |
| | 31 | | } |
| 1 | 32 | | if (!LanguageUtilityClass.IsCorrectLanguageCode(jproperty.Name)) |
| | 33 | | { |
| 0 | 34 | | Warnings.Add(WarningFactory.GetNaturalLanguageWrongValue(jproperty.Value, jproperty.Name)); |
| 0 | 35 | | return; |
| | 36 | | } |
| 1 | 37 | | titlesMap[jproperty.Name] = ((JArray)jproperty.Value).ToObject<string[]>()!; |
| | 38 | |
|
| | 39 | | } |
| 1 | 40 | | Descriptor.titles = new NaturalLanguageProperty(titlesMap); |
| | 41 | | } |
| 1 | 42 | | } |
| | 43 | | } |
| | 44 | | } |