Class DefaultCodecFactory
LUCENENET specific class that implements the default functionality for the
ICodec
The most common use cases are:
- Initialize Default
Codec with a set of CustomFactory Codec .Types - Subclass Default
Codec and override GetFactory Codec(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 GetCodec(String) . - Subclass Default
Codec and override GetFactory Codec so a type new type can be supplied that is not in the Lucene.Type(String) Net. .Codecs. Default Codec Factory. codec Name To Type Map - Subclass Default
Codec to add new or override the default Codec types by overriding Initialize() and calling PutFactory Codec .Type(Type) - Subclass Default
Codec to scan additional assemblies for Codec subclasses in by overriding Initialize() and calling ScanFactory For . For performance reasons, the default behavior only loads Lucene.Net codecs.Codecs(Assembly)
To set the ICodec
Inherited Members
Namespace: Lucene.Net.Codecs
Assembly: Lucene.Net.dll
Syntax
public class DefaultCodecFactory : NamedServiceFactory<Codec>, ICodecFactory, IServiceListable
Constructors
| Improve this Doc View SourceDefaultCodecFactory()
Creates a new instance of Default
Declaration
public DefaultCodecFactory()
Properties
| Improve this Doc View SourceAvailableServices
Gets a list of the available Codecs (by name).
Declaration
public virtual ICollection<string> AvailableServices { get; }
Property Value
Type | Description |
---|---|
ICollection<System. |
A ICollection{string} of Codec names. |
CustomCodecTypes
An array of custom Codec-derived types to be registered. This property
can be initialized during construction of Default
These types will be registered after the default Lucene types, so if a custom type has the same
name as a Lucene Codec (via Codec
Declaration
public IEnumerable<Type> CustomCodecTypes { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<Type> |
Methods
| Improve this Doc View SourceGetCodec(String)
Gets the Codec instance from the provided name
.
Declaration
public virtual Codec GetCodec(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the Codec instance to retrieve. |
Returns
| Improve this Doc View SourceGetCodec(Type)
Gets the Codec instance from the provided type
.
Declaration
protected virtual Codec GetCodec(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The |
Returns
| Improve this Doc View SourceGetCodecType(String)
Gets the Codec name
.
Declaration
protected virtual Type GetCodecType(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the Codec |
Returns
Type | Description |
---|---|
Type | The Codec |
Initialize()
Initializes the codec type cache with the known Codec types.
Override this method (and optionally call base.Initialize()
) to add your
own Codec types by calling Put
If two types have the same name by using the Codec
Declaration
protected override void Initialize()
Overrides
NewCodec(Type)
Instantiates a Codec based on the provided type
.
Declaration
protected virtual Codec NewCodec(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The |
Returns
Type | Description |
---|---|
Codec | The new instance. |
PutCodecType(Type)
Adds a Codec type to the Lucene.
Note that if a Codec with the same name already exists in the map, calling this method will update it to the new type.
Declaration
protected virtual void PutCodecType(Type codec)
Parameters
Type | Name | Description |
---|---|---|
Type | codec | A type that subclasses Codec. |
ScanForCodecs(Assembly)
Scans the given assembly
for subclasses of Codec
and adds their names to the Lucene.
Declaration
protected virtual void ScanForCodecs(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
Assembly | assembly | The assembly to scan. |
ScanForCodecs(IEnumerable<Assembly>)
Scans the given assemblies
for subclasses of Codec
and adds their names to the Lucene.
Declaration
protected virtual void ScanForCodecs(IEnumerable<Assembly> assemblies)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Assembly> | assemblies | A list of assemblies to scan. The assemblies will be scanned from first to last, and the last match for each Codec name wins. |