本文整理汇总了C#中System.CodeDom.Compiler.CodeDomProvider.CreateEscapedIdentifier方法的典型用法代码示例。如果您正苦于以下问题:C# CodeDomProvider.CreateEscapedIdentifier方法的具体用法?C# CodeDomProvider.CreateEscapedIdentifier怎么用?C# CodeDomProvider.CreateEscapedIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CodeDom.Compiler.CodeDomProvider
的用法示例。
在下文中一共展示了CodeDomProvider.CreateEscapedIdentifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EscapeKeywords
private static void EscapeKeywords(string identifier, CodeDomProvider codeProvider, StringBuilder sb)
{
if ((identifier != null) && (identifier.Length != 0))
{
int num = 0;
while (identifier.EndsWith("[]", StringComparison.Ordinal))
{
num++;
identifier = identifier.Substring(0, identifier.Length - 2);
}
if (identifier.Length > 0)
{
CheckValidIdentifier(identifier);
identifier = codeProvider.CreateEscapedIdentifier(identifier);
sb.Append(identifier);
}
for (int i = 0; i < num; i++)
{
sb.Append("[]");
}
}
}
示例2: GenerateAction
static void GenerateAction (CodeTypeReference exportAtt, CodeTypeDeclaration type, IBAction action,
CodeDomProvider provider, CodeGeneratorOptions generatorOptions)
{
if (provider is Microsoft.CSharp.CSharpCodeProvider) {
type.Members.Add (new CodeSnippetTypeMember ("[" + exportAtt.BaseType + "(\"" + action.GetObjcFullName () + "\")]"));
var sb = new System.Text.StringBuilder ();
sb.Append ("partial void ");
sb.Append (provider.CreateEscapedIdentifier (action.CliName));
sb.Append (" (");
if (action.Parameters != null) {
bool isFirst = true;
foreach (var p in action.Parameters) {
if (!isFirst) {
sb.Append (", ");
} else {
isFirst = false;
}
sb.Append (p.CliType);
sb.Append (" ");
sb.Append (provider.CreateEscapedIdentifier (p.Name));
}
}
sb.Append (");");
type.Members.Add (new CodeSnippetTypeMember (sb.ToString ()));
return;
}
var m = CreateEventMethod (exportAtt, action);
type.Members.Add (m);
if (provider.FileExtension == "pas") {
m.UserData ["OxygenePartial"] = "YES";
m.UserData ["OxygeneEmpty"] = "YES";
}
}
示例3: SanitizeResourceName
string SanitizeResourceName (CodeDomProvider provider, string name)
{
if (provider.IsValidIdentifier (name))
return provider.CreateEscapedIdentifier (name);
var sb = new StringBuilder ();
char ch = name [0];
if (is_identifier_start_character (ch))
sb.Append (ch);
else {
sb.Append ('_');
if (ch >= '0' && ch <= '9')
sb.Append (ch);
}
for (int i = 1; i < name.Length; i++) {
ch = name [i];
if (is_identifier_part_character (ch))
sb.Append (ch);
else
sb.Append ('_');
}
return provider.CreateEscapedIdentifier (sb.ToString ());
}