Example #1
0
        private IEnumerable <string> ExtractTaxa(XmlNode context, TaxonType type = TaxonType.Any)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            string typeString = type.ToString().ToLower();
            string xpath      = string.Empty;

            switch (type)
            {
            case TaxonType.Lower:
            case TaxonType.Higher:
                xpath = string.Format("//tn[@type='{0}']|//tp:taxon-name[@type='{0}']", typeString);
                break;

            case TaxonType.Any:
                xpath = "//tn|//tp:taxon-name";
                break;
            }

            var result = new List <string>();

            if (!string.IsNullOrWhiteSpace(xpath))
            {
                result = context.SelectNodesWithTaxPubXmlNamespaceManager(xpath)
                         .Cast <XmlNode>()
                         .Select(this.TaxonNameXmlNodeToString)
                         .Distinct()
                         .ToList();
            }

            return(new HashSet <string>(result));
        }
Example #2
0
        public static XmlElement CreateTaxonNameXmlElement(this IDocument document, TaxonType type)
        {
            XmlElement tn = document.XmlDocument.CreateElement(ElementNames.TaxonName);

            tn.SetAttribute(AttributeNames.Type, type.ToString().ToLower());
            return(tn);
        }
Example #3
0
        public static T GetTaxon <T>(this RealEstateItem realEstateItem, TaxonType taxonType) where T : Taxon
        {
            var ids = (TrackedList <Guid>)realEstateItem.GetValue(taxonType.ToString());

            if (ids != null && ids.Count > 0)
            {
                return(taxonomyManager.GetTaxon <T>(ids[0]));
            }

            return(null);
        }
Example #4
0
        public static List <T> GetTaxons <T>(this RealEstateItem realEstateItem, TaxonType taxonType) where T : Taxon
        {
            List <T> result = new List <T>();
            var      ids    = (TrackedList <Guid>)realEstateItem.GetValue(taxonType.ToString());

            foreach (var id in ids)
            {
                result.Add(taxonomyManager.GetTaxon <T>(id));
            }

            return(result);
        }
Example #5
0
 public static string MapTaxonTypeToTaxonTypeString(this TaxonType type)
 {
     return(type.ToString().ToLower());
 }