コード例 #1
0
 /// <summary>
 /// Add a <see cref="LevelMappingEntry"/> to this mapping
 /// </summary>
 /// <param name="entry">the entry to add</param>
 /// <remarks>
 /// <para>
 /// If a <see cref="LevelMappingEntry"/> has previously been added
 /// for the same <see cref="Level"/> then that entry will be
 /// overwritten.
 /// </para>
 /// </remarks>
 public void Add(LevelMappingEntry entry)
 {
     if (m_entriesMap.ContainsKey(entry.Level))
     {
         m_entriesMap.Remove(entry.Level);
     }
     m_entriesMap.Add(entry.Level, entry);
 }
コード例 #2
0
        /// <summary>
        /// Initialize options
        /// </summary>
        /// <remarks>
        /// <para>
        /// Caches the sorted list of <see cref="LevelMappingEntry"/> in an array
        /// </para>
        /// </remarks>
        public void ActivateOptions()
        {
            Level[]             sortKeys   = new Level[m_entriesMap.Count];
            LevelMappingEntry[] sortValues = new LevelMappingEntry[m_entriesMap.Count];

            m_entriesMap.Keys.CopyTo(sortKeys, 0);
            m_entriesMap.Values.CopyTo(sortValues, 0);

            // Sort in level order
            Array.Sort(sortKeys, sortValues, 0, sortKeys.Length, null);

            // Reverse list so that highest level is first
            Array.Reverse(sortValues, 0, sortValues.Length);

            foreach (LevelMappingEntry entry in sortValues)
            {
                entry.ActivateOptions();
            }

            m_entries = sortValues;
        }