private string GetAttributeByName(ISOElement isoElement, string name) { Dictionary <string, string> schemaProperties = isoElement?.ProprietarySchemaExtensions; if (schemaProperties == null || schemaProperties.Count == 0) { return(string.Empty); } return(schemaProperties.TryGetValue(name, out string value) ? value : string.Empty); }
public string GetCropName(ISOElement isoElement) { var cropTypeAsString = GetAttributeByName(isoElement, CropTypeAttributeName); if (string.IsNullOrEmpty(cropTypeAsString) || !int.TryParse(cropTypeAsString, NumberStyles.Integer, CultureInfo.InvariantCulture, out int cropType) || !_supportedCrops.TryGetValue(cropType, out string cropName)) { return(string.Empty); } return(cropName); }
/// <summary> /// Creates ContextItems out of any proprietary attributes /// </summary> /// <param name="element"></param> /// <returns></returns> public List <ContextItem> ImportContextItemsFromProprietaryAttributes(ISOElement element) { List <ContextItem> output = new List <ContextItem>(); if (element.ProprietarySchemaExtensions != null) { foreach (string key in element.ProprietarySchemaExtensions.Keys) { output.Add(new ContextItem { Code = string.Concat("Pr_", key), //Recommended ContextItem practice is to prefix any items with Pr_ which are not intended to be common industry vocabulary Value = element.ProprietarySchemaExtensions[key] }); } } return(output); }
protected List <ContextItem> ImportContextItems(string isoIDRef, string linkGroupDescription, ISOElement element = null) { //Read any data from the LinkList List <ContextItem> output = UniqueIDMapper.ImportContextItemsFromLinkList(isoIDRef, linkGroupDescription); if (element != null) { //Add any proprietary attributes on the element output.AddRange(UniqueIDMapper.ImportContextItemsFromProprietaryAttributes(element)); } return(output); }