Exemple #1
0
        private Dictionary <string, string> GetDmuIdFromNameLookup()
        {
            // First get all DMU entries
            DescriptionOfMapUnitsAccess DmuAccess = new DescriptionOfMapUnitsAccess(m_theWorkspace);

            DmuAccess.AddDescriptionOfMapUnits();

            // Pass these records into a new Dictionary correlating ID to HierarchyKey
            Dictionary <string, string> idDmuDictionary = new Dictionary <string, string>();

            foreach (KeyValuePair <string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in DmuAccess.DescriptionOfMapUnitsDictionary)
            {
                DescriptionOfMapUnitsAccess.DescriptionOfMapUnit thisDmuEntry = (DescriptionOfMapUnitsAccess.DescriptionOfMapUnit)aDictionaryEntry.Value;
                if (thisDmuEntry.ParagraphStyle.Contains("Heading") == true)
                {
                    idDmuDictionary.Add(thisDmuEntry.Name, thisDmuEntry.DescriptionOfMapUnits_ID);
                }
                else
                {
                    idDmuDictionary.Add(thisDmuEntry.MapUnit + " - " + thisDmuEntry.Name, thisDmuEntry.DescriptionOfMapUnits_ID);
                }
            }

            return(idDmuDictionary);
        }
        private static IOrderedEnumerable <KeyValuePair <string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> > GetDmuSortedByHierarchy(IWorkspace theWorkspace)
        {
            // Get All DescriptionOfMapUnits.
            DescriptionOfMapUnitsAccess DmuAccess = new DescriptionOfMapUnitsAccess(theWorkspace);

            DmuAccess.AddDescriptionOfMapUnits();

            // Sort using Linq syntax
            var sortedDmuEntries = (
                from entry in DmuAccess.DescriptionOfMapUnitsDictionary
                orderby((DescriptionOfMapUnitsAccess.DescriptionOfMapUnit)entry.Value).HierarchyKey ascending
                select entry);

            return(sortedDmuEntries);
        }