コード例 #1
0
ファイル: CNH.cs プロジェクト: lzaslav/ISOv4Plugin
        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);
        }
コード例 #2
0
ファイル: CNH.cs プロジェクト: lzaslav/ISOv4Plugin
        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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
ファイル: BaseMapper.cs プロジェクト: lzaslav/ISOv4Plugin
        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);
        }