Class ParentAwareComponentBase<TParent>
Optional base class for components attached to a class implementing IObjectWithComponents. Adds all functionality of ParentAwareComponentBase, and additionally type-checks the object it's attached to to make sure it is of the given type. It also exposes its Parent property as that type instead of object.
Implements
Inherited Members
Namespace: GoRogue.Components.ParentAware
Assembly: GoRogue.dll
Syntax
public class ParentAwareComponentBase<TParent> : ParentAwareComponentBase, IParentAwareComponent where TParent : class
Type Parameters
Name | Description |
---|---|
TParent | Type of the component's parent. |
Remarks
Like ParentAwareComponentBase, subclasses of this class may be added as a component to any class that implements IObjectWithComponents, however components inheriting from this class will not implicitly fail in any way if it is used with a class that does not implement that interface. Certain functions such as IncompatibleWith<TComponent>(object?, EventArgs) do require that their parent implement IObjectWithComponents, and in general there is no guarantee that the Parent field gets updated if the parent doesn't implement that interface; however you can sync the parent field manually as applicable.
In most cases, the intended usage is to add this as a component to a class that implements IObjectWithComponents; however the option of not doing so and manually syncing the Parent field instead allows this functionality to be tied into other component systems as well.
Constructors
View SourceParentAwareComponentBase()
Constructor.
Declaration
public ParentAwareComponentBase()
Properties
View SourceParent
The object the component is attached to.
Declaration
public virtual TParent? Parent { get; set; }
Property Value
Type | Description |
---|---|
TParent |
Events
View SourceRemoved
Fires when the component is unattached from an object
Declaration
public event EventHandler<ParentAwareComponentRemovedEventArgs<TParent>>? Removed
Event Type
Type | Description |
---|---|
EventHandler<ParentAwareComponentRemovedEventArgs<TParent>> |