Beispiel #1
0
 /// <summary>
 /// Creates a unique name set from the given name-providing function,
 /// and a name-generating function that is used to resolve
 /// collisions. This unique set's name pool is aliased with the given
 /// other unique name set.
 /// </summary>
 /// <param name="getName">
 /// A function that maps values to their preferred names.
 /// </param>
 /// <param name="generateName">
 /// A function that takes a value and an integer and combines
 /// them into a name. This function is called with increasingly
 /// large integers when a collision occurs, until a unique name
 /// is found.
 /// </param>
 /// <param name="alias">
 /// A unique name set with which this unique name set's generated names are
 /// aliased.
 /// </param>
 public UniqueNameSet(
     Func <T, string> getName, Func <T, int, string> generateName,
     UniqueNameSet <T> alias)
 {
     this.getName      = getName;
     this.generateName = generateName;
     this.nameSet      = alias.nameSet;
 }
Beispiel #2
0
 /// <summary>
 /// Creates a unique name map from a unique name set.
 /// </summary>
 /// <param name="nameSet">
 /// A pre-existing unique name set to use.
 /// </param>
 public UniqueNameMap(UniqueNameSet <T> nameSet)
 {
     this.nameSet = nameSet;
     this.dict    = new ConcurrentDictionary <T, string>();
 }
Beispiel #3
0
        /// <summary>
        /// Creates a unique name set from the given name-providing function,
        /// and a prefix that is used to resolve collisions. This unique set's
        /// name pool is aliased with another unique name set.
        /// </summary>
        /// <param name="getName">
        /// A function that maps values to their preferred names.
        /// </param>
        /// <param name="prefix">
        /// A string prefix that is used to generate a unique name when a
        /// collision occurs.
        /// </param>
        /// <param name="alias">
        /// A unique name set with which this unique name set's generated names are
        /// aliased.
        /// </param>

        public UniqueNameSet(Func <T, string> getName, string prefix, UniqueNameSet <T> alias)
        {
            this.getName      = getName;
            this.generateName = new PrefixNameGenerator <T>(prefix).GenerateName;
            this.nameSet      = alias.nameSet;
        }