/// <summary> /// Creates a template resource name with the given root name.<para/> /// For example, if <paramref name="rootName"/> is <c>"Equation"</c> and the document /// contains no resources, then this method will return <c>"Equation 1"</c>. However, /// calling this method again with the same root name will return <c>"Equation 2"</c>, /// as <c>"Equation 1"</c> is already taken. Removing <c>"Equation 1"</c> from the /// document and calling this method again with the same parameters will again return /// <c>"Equation 1"</c>, as that is the first root name available. /// </summary> /// <param name="rootName">The root resource type name to create a resource name for.</param> private string CreateResourceName(string rootName) { int currentNumber = 0; string derivedName; do { currentNumber += 1; derivedName = String.Format("{0} {1}", rootName, currentNumber); } while (CurrentDocument.Any(r => r.Name.ToLowerInvariant() == derivedName.ToLowerInvariant())); return(derivedName); }