SobekCM.Core.UI_Configuration.Citation.CitationFieldSet.Remove_Element C# (CSharp) Method

Remove_Element() public method

Removes a single citation element from this field set, if it exists
public Remove_Element ( string MetadataTerm ) : void
MetadataTerm string Unique identifier for the citation element to remove
return void
        public void Remove_Element(string MetadataTerm)
        {
            // Ensure the dictionary is built (i.e., not null)
            if (elementsDictionary == null) elementsDictionary = new Dictionary<string, CitationElement>( StringComparer.OrdinalIgnoreCase );

            // Check that the count in the dictionary seems right
            if (elementsDictionary.Count != Elements.Count)
            {
                foreach (CitationElement thisElement in Elements)
                    elementsDictionary[thisElement.MetadataTerm] = thisElement;
            }

            // If this doesn't exist, do nothin
            if (!elementsDictionary.ContainsKey(MetadataTerm))
                return;

            // Find the match from the dictionary first
            CitationElement match = elementsDictionary[MetadataTerm];
            Elements.Remove(match);
            elementsDictionary.Remove(MetadataTerm);
        }