/// <summary> /// Constructor takes the token type and the string that /// represents the token. /// If the string may contain content that needs expansion, expandable is set. /// </summary> internal Token(TokenType type, string tokenString, bool expandable) { ErrorUtilities.VerifyThrow ( type == TokenType.Property || type == TokenType.String || type == TokenType.Numeric || type == TokenType.ItemList || type == TokenType.ItemMetadata || type == TokenType.Function, "Unexpected token type" ); ErrorUtilities.VerifyThrowInternalNull(tokenString, "tokenString"); _tokenType = type; _tokenString = tokenString; this.Expandable = expandable; }
/// <summary> /// Cleanse the project name, by replacing characters like '@', '$' with '_' /// </summary> /// <param name="projectName">The name to be cleansed</param> /// <returns>string</returns> static private string CleanseProjectName(string projectName) { ErrorUtilities.VerifyThrow(projectName != null, "Null strings not allowed."); // If there are no special chars, just return the original string immediately. // Don't even instantiate the StringBuilder. int indexOfChar = projectName.IndexOfAny(s_charsToCleanse); if (indexOfChar == -1) { return(projectName); } // This is where we're going to work on the final string to return to the caller. StringBuilder cleanProjectName = new StringBuilder(projectName); // Replace each unclean character with a clean one foreach (char uncleanChar in s_charsToCleanse) { cleanProjectName.Replace(uncleanChar, cleanCharacter); } return(cleanProjectName.ToString()); }