Class DefaultPostingsFormatFactory
LUCENENET specific class that implements the default functionality for the IPostingsFormatFactory.
The most common use cases are:
- Initialize DefaultPostingsFormatFactory with a set of CustomPostingsFormatTypes.
- Subclass DefaultPostingsFormatFactory and override GetPostingsFormat(Type) so an external dependency injection container can be used to supply the instances (lifetime should be singleton). Note that you could alternately use the "named type" feature that many DI containers have to supply the type based on name by overriding GetPostingsFormat(String).
- Subclass DefaultPostingsFormatFactory and override GetPostingsFormatType(String) so a type new type can be supplied that is not in the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap.
- Subclass DefaultPostingsFormatFactory to add new or override the default PostingsFormat types by overriding Initialize() and calling PutPostingsFormatType(Type).
- Subclass DefaultPostingsFormatFactory to scan additional assemblies for PostingsFormat subclasses in by overriding Initialize() and calling ScanForPostingsFormats(Assembly). For performance reasons, the default behavior only loads Lucene.Net codecs.
To set the IPostingsFormatFactory, call SetPostingsFormatFactory(IPostingsFormatFactory).
Inherited Members
Namespace: Lucene.Net.Codecs
Assembly: Lucene.Net.dll
Syntax
public class DefaultPostingsFormatFactory : NamedServiceFactory<PostingsFormat>, IPostingsFormatFactory, IServiceListable
Constructors
| Improve this Doc View SourceDefaultPostingsFormatFactory()
Creates a new instance of DefaultPostingsFormatFactory.
Declaration
public DefaultPostingsFormatFactory()
Properties
| Improve this Doc View SourceAvailableServices
Gets a list of the available PostingsFormats (by name).
Declaration
public virtual ICollection<string> AvailableServices { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<System.String> | A ICollection{string} of PostingsFormat names. |
CustomPostingsFormatTypes
An array of custom PostingsFormat-derived types to be registered. This property can be initialized during construction of DefaultPostingsFormatFactory to make your custom codecs known to Lucene.
These types will be registered after the default Lucene types, so if a custom type has the same name as a Lucene PostingsFormat (via PostingsFormatNameAttribute) the custom type will replace the Lucene type with the same name.
Declaration
public IEnumerable<Type> CustomPostingsFormatTypes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Type> |
Methods
| Improve this Doc View SourceGetPostingsFormat(String)
Gets the PostingsFormat instance from the provided name
.
Declaration
public virtual PostingsFormat GetPostingsFormat(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the PostingsFormat instance to retrieve. |
Returns
Type | Description |
---|---|
PostingsFormat | The PostingsFormat instance. |
GetPostingsFormat(Type)
Gets the PostingsFormat instance from the provided type
.
Declaration
protected virtual PostingsFormat GetPostingsFormat(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The System.Type of PostingsFormat to retrieve. |
Returns
Type | Description |
---|---|
PostingsFormat | The PostingsFormat instance. |
GetPostingsFormatType(String)
Gets the PostingsFormat System.Type from the provided name
.
Declaration
protected virtual Type GetPostingsFormatType(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the PostingsFormat System.Type to retrieve. |
Returns
Type | Description |
---|---|
System.Type | The PostingsFormat System.Type. |
Initialize()
Initializes the codec type cache with the known PostingsFormat types.
Override this method (and optionally call base.Initialize()
) to add your
own PostingsFormat types by calling PutPostingsFormatType(Type)
or ScanForPostingsFormats(Assembly).
If two types have the same name by using the PostingsFormatNameAttribute, the last one registered wins.
Declaration
protected override void Initialize()
Overrides
NewPostingsFormat(Type)
Instantiates a PostingsFormat based on the provided type
.
Declaration
protected virtual PostingsFormat NewPostingsFormat(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The System.Type of PostingsFormat to instantiate. |
Returns
Type | Description |
---|---|
PostingsFormat | The new instance. |
PutPostingsFormatType(Type)
Adds a PostingsFormat type to the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap, using the name provided in the PostingsFormatNameAttribute, if present, or the name of the codec class minus the "Codec" suffix as the name by default.
Note that if a PostingsFormat with the same name already exists in the map, calling this method will update it to the new type.
Declaration
protected virtual void PutPostingsFormatType(Type postingsFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Type | postingsFormat | A type that subclasses PostingsFormat. |
ScanForPostingsFormats(IEnumerable<Assembly>)
Scans the given assemblies
for subclasses of Codec
and adds their names to the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap. Note that names will be
automatically overridden if the PostingsFormat name appears multiple times - the last match wins.
Declaration
protected virtual void ScanForPostingsFormats(IEnumerable<Assembly> assemblies)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | A list of assemblies to scan. The assemblies will be scanned from first to last, and the last match for each PostingsFormat name wins. |
ScanForPostingsFormats(Assembly)
Scans the given assembly
for subclasses of PostingsFormat
and adds their names to the Lucene.Net.Codecs.DefaultPostingsFormatFactory.postingsFormatNameToTypeMap. Note that names will be
automatically overridden if the PostingsFormat name appears multiple times - the last match wins.
Declaration
protected virtual void ScanForPostingsFormats(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The assembly to scan. |