Exemple #1
0
        private string GetUniqueKey(string key)
        {
            string uniqueKey = key;

            VToken token     = null;
            bool   keyExists = tokens.TryGetValue(key, out token);

            if (keyExists)
            {
                // try to get the count of this duplicate key so we can roll the number and add appropriately
                int  count   = 0;
                bool success = duplicateKeyCounts.TryGetValue(key, out count);
                count++;

                if (success)
                {
                    // increase the duplicate count
                    duplicateKeyCounts[key] = count;
                }
                else
                {
                    duplicateKeyCounts.Add(key, count);
                }

                // create our new unique key with the appended increased count
                uniqueKey = String.Format("{0}-{1}", key, count);
            }

            return(uniqueKey);
        }
Exemple #2
0
        /// <summary>
        /// Adds a new token of any type to the collection.
        /// </summary>
        /// <param name="token"></param>
        public void AddToken(VToken token)
        {
            string uniqueKey = GetUniqueKey(token.Key);

            tokens.Add(uniqueKey, token);
        }