Class ComponentContainer<TContainer, TComponent>
Base class that stores a set of hierarchical components by type.
Other TContainer
can be added as dependencies to get inherited or overridden components.
Inheritance
Inherited Members
Namespace: Unity.Build
Syntax
public class ComponentContainer<TContainer, TComponent> : ScriptableObjectPropertyContainer<TContainer>, ISerializationCallbackReceiver where TContainer : ComponentContainer<TContainer, TComponent>
Type Parameters
Name | Description |
---|---|
TContainer | Type of the component container. |
TComponent | Components base type. |
Methods
AddDependency(TContainer)
Add a dependency to this container. Circular dependencies or dependencies on self are not allowed.
Declaration
public bool AddDependency(TContainer dependency)
Parameters
Type | Name | Description |
---|---|---|
TContainer | dependency | The dependency to add. |
Returns
Type | Description |
---|---|
Boolean | true if the dependency was added, false otherwise. |
ClearComponents()
Remove all components from this container.
Declaration
public void ClearComponents()
ClearDependencies()
Remove all dependencies from this container.
Declaration
public void ClearDependencies()
GetComponent(Type)
Get the value of a Type component.
Declaration
public TComponent GetComponent(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the component. |
Returns
Type | Description |
---|---|
TComponent |
GetComponent<T>()
Get the value of a T
component.
Declaration
public T GetComponent<T>()
where T : TComponent
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | Type of the component. |
GetComponents()
Get a flatten list of all components from this container and its dependencies.
Declaration
public List<TComponent> GetComponents()
Returns
Type | Description |
---|---|
List<TComponent> |
GetDependencies()
Get a flatten list of all dependencies recursively from this container and its dependencies.
Declaration
public IEnumerable<TContainer> GetDependencies()
Returns
Type | Description |
---|---|
IEnumerable<TContainer> | List of dependencies. |
HasComponent(Type)
Determine if a Type component is stored in this container or its dependencies.
Declaration
public bool HasComponent(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the component. |
Returns
Type | Description |
---|---|
Boolean |
HasComponent<T>()
Determine if a T
component is stored in this container or its dependencies.
Declaration
public bool HasComponent<T>()
where T : TComponent
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | Type of the component. |
HasDependency(TContainer)
Determine if a dependency exist in this container or its dependencies.
Declaration
public bool HasDependency(TContainer dependency)
Parameters
Type | Name | Description |
---|---|---|
TContainer | dependency | The dependency to search. |
Returns
Type | Description |
---|---|
Boolean | true if the dependency is found, false otherwise. |
IsComponentInherited(Type)
Determine if a Type component is inherited from a dependency.
Declaration
public bool IsComponentInherited(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the component. |
Returns
Type | Description |
---|---|
Boolean |
IsComponentInherited<T>()
Determine if a T
component is inherited from a dependency.
Declaration
public bool IsComponentInherited<T>()
where T : TComponent
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | Type of the component. |
IsComponentOverridden(Type)
Determine if a Type component overrides a dependency.
Declaration
public bool IsComponentOverridden(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the component. |
Returns
Type | Description |
---|---|
Boolean |
IsComponentOverridden<T>()
Determine if a T
component overrides a dependency.
Declaration
public bool IsComponentOverridden<T>()
where T : TComponent
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | Type of the component. |
RemoveComponent(Type)
Remove a Type component from this container.
Declaration
public bool RemoveComponent(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the component. |
Returns
Type | Description |
---|---|
Boolean |
RemoveComponent<T>()
Remove a T
component from this container.
Declaration
public bool RemoveComponent<T>()
where T : TComponent
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | Type of the component. |
RemoveDependency(TContainer)
Remove a dependency from this container.
Declaration
public bool RemoveDependency(TContainer dependency)
Parameters
Type | Name | Description |
---|---|---|
TContainer | dependency | The dependency to remove. |
Returns
Type | Description |
---|---|
Boolean |
Reset()
Declaration
protected override void Reset()
Overrides
Sanitize()
Declaration
protected override void Sanitize()
Overrides
SetComponent(Type, TComponent)
Set the value of a Type component on this container.
Declaration
public void SetComponent(Type type, TComponent value)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the component. |
TComponent | value | Value of the component to set. |
SetComponent<T>(T)
Set the value of a T
component on this container.
Declaration
public void SetComponent<T>(T value)
where T : TComponent
Parameters
Type | Name | Description |
---|---|---|
T | value | Value of the component to set. |
Type Parameters
Name | Description |
---|---|
T | Type of the component. |
SetDependencies(TContainer[])
Override the dependencies on this container.
Declaration
public void SetDependencies(TContainer[] dependencies)
Parameters
Type | Name | Description |
---|---|---|
TContainer[] | dependencies |
TryGetComponent(Type, out TComponent)
Try to get the value of a Type component.
Declaration
public bool TryGetComponent(Type type, out TComponent value)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type of the component. |
TComponent | value | Out value of the component. |
Returns
Type | Description |
---|---|
Boolean |
TryGetComponent<T>(out T)
Try to get the value of a T
component.
Declaration
public bool TryGetComponent<T>(out T value)
where T : TComponent
Parameters
Type | Name | Description |
---|---|---|
T | value | Out value of the component. |
Returns
Type | Description |
---|---|
Boolean |
Type Parameters
Name | Description |
---|---|
T | Type of the component. |
VisitComponents(IPropertyVisitor)
Visit a flatten list of all components from this container and its dependencies.
Declaration
public void VisitComponents(IPropertyVisitor visitor)
Parameters
Type | Name | Description |
---|---|---|
IPropertyVisitor | visitor | The visitor to use for visiting each component. |