internal List<CodeMemberMethod> createEventHooks()
{
string[] eventNames = new string[] { "OnUpdate", "OnInsert", "OnDelete", "OnSelect", "OnSelectAll" };
List<CodeMemberMethod> eventHooks = new List<CodeMemberMethod>();
foreach (string eventName in eventNames)
{
CodeMemberMethod eventHook = new CodeMemberMethod();
eventHook.Name = eventName;
eventHook.Attributes = MemberAttributes.ScopeMask;
eventHook.ReturnType = new CodeTypeReference("partial void");
}
return eventHooks;
}
is producing the following code:
partial void OnUpdate() {
}
partial void OnInsert() {
}
partial void OnDelete() {
}
partial void OnSelect() {
}
partial void OnSelectAll() {
}
How can I get CodeDom to drop the "{}
", which will resolve the compiler error I'm getting trying to compile? I thought of just using a CodeSnippetStatement
(which I would rather not do, since this defeats the purpose of using CodeDom in the first place), but I can't find a place in the CodeTypeDeclaration
class to add snippets.
So: I need to either
- Add an implementation-less method to a class
- Add a random snippet to a class
- Mystery 3rd option