Class CollectionBuilderBase<TBuilder, TCollection, TItem>
Provides a base class for collection builders.
Inheritance
Namespace: Umbraco.Cms.Core.Composing
Assembly: Umbraco.Core.dll
Syntax
public abstract class CollectionBuilderBase<TBuilder, TCollection, TItem> : ICollectionBuilder<TCollection, TItem>, ICollectionBuilder where TBuilder : CollectionBuilderBase<TBuilder, TCollection, TItem> where TCollection : class, IBuilderCollection<TItem>
Type Parameters
Name | Description |
---|---|
TBuilder | The type of the builder. |
TCollection | The type of the collection. |
TItem | The type of the items. |
Properties
View SourceCollectionLifetime
Gets the collection lifetime.
Declaration
protected virtual ServiceLifetime CollectionLifetime { get; }
Property Value
Type | Description |
---|---|
ServiceLifetime |
Methods
View SourceConfigure(Action<List<Type>>)
Configures the internal list of types.
Declaration
protected void Configure(Action<List<Type>> action)
Parameters
Type | Name | Description |
---|---|---|
Action<List<Type>> | action | The action to execute. |
Remarks
Throws if the types have already been registered.
CreateCollection(IServiceProvider)
Creates a collection.
Declaration
public virtual TCollection CreateCollection(IServiceProvider factory)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | factory |
Returns
Type | Description |
---|---|
TCollection | A collection. |
Remarks
Creates a new collection each time it is invoked.
CreateItem(IServiceProvider, Type)
Creates a collection item.
Declaration
protected virtual TItem CreateItem(IServiceProvider factory, Type itemType)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | factory | |
Type | itemType |
Returns
Type | Description |
---|---|
TItem |
CreateItems(IServiceProvider)
Creates the collection items.
Declaration
protected virtual IEnumerable<TItem> CreateItems(IServiceProvider factory)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | factory |
Returns
Type | Description |
---|---|
IEnumerable<TItem> | The collection items. |
EnsureType(Type, String)
Declaration
protected Type EnsureType(Type type, string action)
Parameters
Type | Name | Description |
---|---|---|
Type | type | |
System.String | action |
Returns
Type | Description |
---|---|
Type |
GetRegisteringTypes(IEnumerable<Type>)
Gets the types.
Declaration
protected virtual IEnumerable<Type> GetRegisteringTypes(IEnumerable<Type> types)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Type> | types | The internal list of types. |
Returns
Type | Description |
---|---|
IEnumerable<Type> | The list of types to register. |
Remarks
Used by implementations to add types to the internal list, sort the list, etc.
GetTypes()
Gets the internal list of types as an IEnumerable (immutable).
Declaration
public IEnumerable<Type> GetTypes()
Returns
Type | Description |
---|---|
IEnumerable<Type> |
Has(Type)
Gets a value indicating whether the collection contains a type.
Declaration
public virtual bool Has(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type to look for. |
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the collection contains the type. |
Remarks
Some builder implementations may use this to expose a public Has{T}() method, when it makes sense. Probably does not make sense for lazy builders, for example.
Has<T>()
Gets a value indicating whether the collection contains a type.
Declaration
public virtual bool Has<T>()
where T : TItem
Returns
Type | Description |
---|---|
System.Boolean | A value indicating whether the collection contains the type. |
Type Parameters
Name | Description |
---|---|
T | The type to look for. |
Remarks
Some builder implementations may use this to expose a public Has{T}() method, when it makes sense. Probably does not make sense for lazy builders, for example.
RegisterWith(IServiceCollection)
Registers the builder so it can build the collection, by registering the collection and the types.
Declaration
public virtual void RegisterWith(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
IServiceCollection | services |