public virtual string CreateValidIdentifier(string value) { ICodeGenerator cg = CreateGenerator(); if (cg == null) { throw GetNotImplemented(); } return(cg.CreateValidIdentifier(value)); }
public void TestCreateValidIdentifierNullArg() { gen.CreateValidIdentifier(null); }
public void ICodeGeneratorCreateValidIdentifier_Invoke_ReturnsExpected() { ICodeGenerator generator = this; Assert.Equal("validIdentifier", generator.CreateValidIdentifier(null)); }
public string CreateValidIdentifier(string value) { return(_generator.CreateValidIdentifier(value)); }
public static string MakeSafeName (string name, ICodeGenerator codeGen) { if (name == null || codeGen == null) throw new NullReferenceException (); name = codeGen.CreateValidIdentifier (name); return MakeSafeNameInternal (name); }
public static string MakeSafeName (string name, ICodeGenerator codeGen) { if (name == null || codeGen == null) throw new NullReferenceException (); name = codeGen.CreateValidIdentifier (name); if (name.Length == 0) return "_"; StringBuilder sb = null; if (!Char.IsLetter (name, 0) && name [0] != '_') { sb = new StringBuilder (); sb.Append ('_'); } int start = 0; for (int i = 0; i < name.Length; i++) { if (!Char.IsLetterOrDigit (name, i)) { if (sb == null) sb = new StringBuilder (); sb.Append (name, start, i - start); sb.Append ('_'); start = i + 1; } } if (sb != null) { sb.Append (name, start, name.Length - start); return sb.ToString (); } else return name; }