Show / Hide Table of Contents

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.

Inheritance
object
ParentAwareComponentBase
ParentAwareComponentBase<TParent>
Implements
IParentAwareComponent
Inherited Members
ParentAwareComponentBase.ParentTypeCheck<TParent>(object, EventArgs)
ParentAwareComponentBase.IncompatibleWith<TComponent>(object, EventArgs)
ParentAwareComponentBase.Added
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
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 Source

ParentAwareComponentBase()

Constructor.

Declaration
public ParentAwareComponentBase()

Properties

View Source

Parent

The object the component is attached to.

Declaration
public virtual TParent? Parent { get; set; }
Property Value
Type Description
TParent

Events

View Source

Removed

Fires when the component is unattached from an object

Declaration
public event EventHandler<ParentAwareComponentRemovedEventArgs<TParent>>? Removed
Event Type
Type Description
EventHandler<ParentAwareComponentRemovedEventArgs<TParent>>

Implements

IParentAwareComponent

Extension Methods

Utility.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX