Unique name creation


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. private string GetUniqueAnimationName(string animationName)
  2. {
  3. Precondition.ArgumentNotNull(animationName, "animationName");
  4.  
  5. foreach (IKeyFrameDictionary dictionary in
  6. m_Context.ActiveConfiguration.AnimationManager.KeyFrameDictionaries.Values)
  7. {
  8. if (dictionary.Name.Equals(animationName))
  9. {
  10. string lastChar = animationName[animationName.Length - 1].ToString();
  11. int currentNumber = 1;
  12.  
  13. if (Int32.TryParse(lastChar, out currentNumber))
  14. {
  15. currentNumber++;
  16. animationName =
  17. animationName.Substring(0, animationName.Length - 1) +
  18. currentNumber.ToString();
  19. }
  20. else
  21. {
  22. animationName = animationName + currentNumber.ToString();
  23. }
  24.  
  25. return GetUniqueAnimationName(animationName);
  26. }
  27. }
  28.  
  29. return animationName;
  30. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.