Class DefaultDataConversionService
A default data conversion service.
Inherited Members
Namespace: Kephas.Data.Conversion
Assembly: Kephas.Data.dll
Syntax
[OverridePriority(Priority.Low)]
public class DefaultDataConversionService : Loggable, ILoggable, IDataConversionService
Constructors
| Improve this Doc View SourceDefaultDataConversionService(ICompositionContext, ICollection<IExportFactory<IDataConverter, DataConverterMetadata>>, ICollection<IExportFactory<IDataConversionTargetResolver, DataConversionTargetResolverMetadata>>)
Initializes a new instance of the DefaultDataConversionService class.
Declaration
public DefaultDataConversionService(ICompositionContext compositionContext, ICollection<IExportFactory<IDataConverter, DataConverterMetadata>> converterExportFactories, ICollection<IExportFactory<IDataConversionTargetResolver, DataConversionTargetResolverMetadata>> targetResolverFactories)
Parameters
Type | Name | Description |
---|---|---|
ICompositionContext | compositionContext | The composition context. |
System.Collections.Generic.ICollection<IExportFactory<IDataConverter, DataConverterMetadata>> | converterExportFactories | The converter export factories. |
System.Collections.Generic.ICollection<IExportFactory<IDataConversionTargetResolver, DataConversionTargetResolverMetadata>> | targetResolverFactories | The target resolver factories. |
Properties
| Improve this Doc View SourceCompositionContext
Gets a context for the dependency injection/composition.
Declaration
public ICompositionContext CompositionContext { get; }
Property Value
Type | Description |
---|---|
ICompositionContext | The composition context. |
Methods
| Improve this Doc View SourceConvertAsync<TSource, TTarget>(TSource, TTarget, IDataConversionContext, CancellationToken)
Converts the source object to the target object asynchronously.
Declaration
public Task<IDataConversionResult> ConvertAsync<TSource, TTarget>(TSource source, TTarget target, IDataConversionContext conversionContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TSource | source | The source object. |
TTarget | target | The target object. |
IDataConversionContext | conversionContext | The conversion context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IDataConversionResult> | A data conversion result. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the source object. |
TTarget | The type of the target object. |
ConvertCoreAsync(Object, TypeInfo, Object, TypeInfo, IDataConversionContext, CancellationToken)
Converts the source object to the target object asynchronously.
Declaration
protected virtual Task<IDataConversionResult> ConvertCoreAsync(object source, TypeInfo sourceType, object target, TypeInfo targetType, IDataConversionContext conversionContext, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Object | source | The source object. |
System.Reflection.TypeInfo | sourceType | The type of the source object. |
System.Object | target | The target object. |
System.Reflection.TypeInfo | targetType | The type of the target object. |
IDataConversionContext | conversionContext | The conversion context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<IDataConversionResult> | A data conversion result. |
CreateDataConversionResult()
Creates a data conversion result.
Declaration
protected virtual IDataConversionResult CreateDataConversionResult()
Returns
Type | Description |
---|---|
IDataConversionResult | The new data conversion result. |
CreateTargetEntityAsync(IDataContext, TypeInfo, IDataConversionContext, CancellationToken)
Creates the target entity asynchronously.
Declaration
protected virtual Task<object> CreateTargetEntityAsync(IDataContext targetDataContext, TypeInfo targetType, IDataConversionContext conversionContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | targetDataContext | Context for the target data. |
System.Reflection.TypeInfo | targetType | The type of the target object. |
IDataConversionContext | conversionContext | The conversion context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the new target entity. |
EnsureTargetEntity(Object, Object, TypeInfo, IDataConversionContext, CancellationToken)
Ensures that a target entity is retrieved or created.
Declaration
protected virtual Task<object> EnsureTargetEntity(object source, object target, TypeInfo targetType, IDataConversionContext conversionContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Object | source | The source object. |
System.Object | target | The target object. |
System.Reflection.TypeInfo | targetType | The type of the target object. |
IDataConversionContext | conversionContext | The conversion context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the target entity. |
GetInstanceTypeInfo(Object, Type, Type, IDataConversionContext)
Gets the type information for the instance.
Declaration
protected virtual TypeInfo GetInstanceTypeInfo(object instance, Type declaredType, Type providedType, IDataConversionContext conversionContext)
Parameters
Type | Name | Description |
---|---|---|
System.Object | instance | The instance. |
System.Type | declaredType | Type of the declared. |
System.Type | providedType | Type of the provided. |
IDataConversionContext | conversionContext | The conversion context. |
Returns
Type | Description |
---|---|
System.Reflection.TypeInfo | The instance type information. |
InvokeConvertersAsync(IEnumerable<IDataConverter>, Object, Object, IDataConversionContext, CancellationToken)
Invokes the converters asynchronously for the convert operation.
Declaration
protected virtual Task<IList<IDataConversionResult>> InvokeConvertersAsync(IEnumerable<IDataConverter> matchingConverters, object source, object target, IDataConversionContext conversionContext, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IDataConverter> | matchingConverters | The matching converters. |
System.Object | source | The source object. |
System.Object | target | The target object. |
IDataConversionContext | conversionContext | The conversion context. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IList<IDataConversionResult>> | The list of results from converters. |
TryResolveTargetEntityAsync(IDataContext, TypeInfo, Object, IEntityEntry, CancellationToken)
Tries to resolve the target entity asynchronously.
Declaration
protected virtual Task<object> TryResolveTargetEntityAsync(IDataContext targetDataContext, TypeInfo targetType, object sourceEntity, IEntityEntry sourceEntityEntry, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | targetDataContext | Context for the target data. |
System.Reflection.TypeInfo | targetType | The type of the target object. |
System.Object | sourceEntity | The source entity. |
IEntityEntry | sourceEntityEntry | The source entity entry. |
System.Threading.CancellationToken | cancellationToken | The cancellation token (optional). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | A promise of the target entity. |