Skip to content

Instantly share code, notes, and snippets.

@mzaks
Last active October 11, 2015 10:47
Show Gist options
  • Select an option

  • Save mzaks/567cef2bb224ba9b6eaa to your computer and use it in GitHub Desktop.

Select an option

Save mzaks/567cef2bb224ba9b6eaa to your computer and use it in GitHub Desktop.
Extract component type name from member reference expression and add it to the type names set
static void AddType (MemberReferenceExpression identifier, HashSet<string> typeNames, HashSet<string> componentTypes)
{
var memberName = UppercaseFirst(identifier.MemberName);
if(!componentTypes.Contains(memberName)){
foreach(string prefix in new string[]{"Has", "Add", "Is", "Replace", "Remove", "Set"}){
if(memberName.StartsWith(prefix)){
memberName = memberName.TrimStart(prefix.ToCharArray());
break;
}
}
}
if(componentTypes.Contains(memberName)){
typeNames.Add (memberName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment