Exemple #1
0
 /// <summary>
 /// Retrieve the cached instance of the NodeSorter
 /// </summary>
 /// <returns></returns>
 public static NodeSorter GetInstance()
 {
     if (_instance == null)
     {
         _instance = new NodeSorter();
     }
     return(_instance);
 }
Exemple #2
0
        /// <summary>
        /// Write the whole dictionary to a stream with optional alphabetical sorting
        /// </summary>
        /// <param name="sw">The stream to write to</param>
        /// <param name="sortFirst">Whether the words should be sorted</param>
        public void WriteToStream(StreamWriter sw, bool sortFirst)
        {
            if (sortFirst)
            {
                Children.Sort(NodeSorter.GetInstance());
            }

            foreach (DictNode n in Children)
            {
                n.WriteToStream(sw, true);
            }
        }
Exemple #3
0
        /// <summary>
        /// Serialise the node as part of a full tree write
        /// </summary>
        /// <param name="sw">The stream to write to</param>
        /// <param name="sortFirst">True to alphabetically sort the child nodes first</param>
        public void WriteToStream(StreamWriter sw, bool sortFirst)
        {
            if (sortFirst)
            {
                Children.Sort(NodeSorter.GetInstance());
            }

            if (_isWord)
            {
                sw.WriteLine(this.ToString());
            }

            foreach (DictNode n in Children)
            {
                n.WriteToStream(sw, sortFirst);
            }
        }