EventBuilder¶
Create event declarations.
See also: Emit Overview | TypeBuilder
Factory Methods¶
| Method | Description |
|---|---|
For(string name, string type) |
Create an event (e.g., "PropertyChanged", "PropertyChangedEventHandler?") |
For<T>(string name, ValidSymbol<T> type) |
Create an event using a symbol's globally qualified name |
Modifiers¶
event.WithAccessibility(Accessibility.Public)
event.WithAccessibility("public") // from snapshot or ValidSymbol.AccessibilityString
event.AsStatic()
event.AsVirtual()
event.AsOverride()
event.AsAbstract()
Conditional Compilation¶
Attributes & XML Documentation¶
event.WithAttribute("NonSerialized")
event.WithAttribute("Obsolete", a => a.WithArgument("\"Use NewEvent\""))
event.WithAttribute(preConfiguredAttribute)
event.WithXmlDoc("Raised when a property changes.")
event.WithXmlDoc(doc => doc.Summary("Raised when a property changes."))
event.WithXmlDoc(documentationSnapshot)
event.AddUsing("System.ComponentModel")
Example¶
var changed = EventBuilder.For("PropertyChanged", "PropertyChangedEventHandler?")
.WithAccessibility(Accessibility.Public)
.WithXmlDoc("Occurs when a property value changes.");
// Add to type
typeBuilder.AddEvent(changed)