BExIS.Ddm.Providers.LuceneProvider.SearchDesigner.GetAllXPathsOfSimpleAttributes C# (CSharp) Method

GetAllXPathsOfSimpleAttributes() public method

public GetAllXPathsOfSimpleAttributes ( long id ) : List
id long
return List
        public List<SearchMetadataNode> GetAllXPathsOfSimpleAttributes(long id)
        {
            List<SearchMetadataNode> list = new List<SearchMetadataNode>();

            // load metadatastructure with all packages and attributes

                MetadataStructureManager msd = new MetadataStructureManager();
                string title = msd.Repo.Get(id).Name;

                XmlMetadataWriter xmlMetadatWriter = new XmlMetadataWriter(XmlNodeMode.xPath);
                XDocument metadataXml = xmlMetadatWriter.CreateMetadataXml(id);

                List<XElement> elements = metadataXml.Root.Descendants().Where(e => e.HasElements.Equals(false)).ToList();

                foreach (XElement element in elements)
                {
                    list.Add(
                        new SearchMetadataNode(title, XExtentsions.GetAbsoluteXPath(element).Substring(1))
                        );
                }

            return list;
        }

Usage Example

 /// <summary>
 /// Get all simple attributes of a metadata Structure
 /// </summary>
 /// <param name="metadatastructureId"></param>
 /// <returns></returns>
 private List<SearchMetadataNode> GetAllXPath(long metadatastructureId)
 {
     SearchDesigner searchDesigner = new SearchDesigner();
     return searchDesigner.GetAllXPathsOfSimpleAttributes(metadatastructureId);
 }