Do not allow constant names to start with numbers.

This commit is contained in:
the_fiddler 2009-08-15 17:32:35 +00:00
parent 070ba4ba59
commit 1da12e8a0b

View file

@ -46,7 +46,7 @@ namespace Bind.Structures
set set
{ {
if (!String.IsNullOrEmpty(value)) if (!String.IsNullOrEmpty(value))
_name = Translate(value.Trim()); _name = Translate(value.Trim(), false);
else _name = value; else _name = value;
PreviousName = value; PreviousName = value;
@ -105,7 +105,7 @@ namespace Bind.Structures
} }
} }
_value = Translate(value); _value = Translate(value, true);
} }
} }
@ -166,9 +166,9 @@ namespace Bind.Structures
#endregion #endregion
#region public static string Translate(string s) #region Translate
public static string Translate(string s) public static string Translate(string s, bool isValue)
{ {
translator.Remove(0, translator.Length); translator.Remove(0, translator.Length);
@ -178,6 +178,9 @@ namespace Bind.Structures
bool next_char_uppercase = true; bool next_char_uppercase = true;
bool is_after_digit = false; bool is_after_digit = false;
if (!isValue && Char.IsDigit(s[0]))
translator.Insert(0, Settings.ConstantPrefix);
foreach (char c in s) foreach (char c in s)
{ {
if (c == '_') if (c == '_')