Show / Hide Table of Contents

Class DefaultDataConversionService

A default data conversion service.

Inheritance
System.Object
Loggable
DefaultDataConversionService
Implements
ILoggable
IDataConversionService
Inherited Members
Loggable.Logger
Loggable.GetLogger()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Kephas.Data.Conversion
Assembly: Kephas.Data.dll
Syntax
[OverridePriority(Priority.Low)]
public class DefaultDataConversionService : Loggable, ILoggable, IDataConversionService

Constructors

| Improve this Doc View Source

DefaultDataConversionService(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 Source

CompositionContext

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 Source

ConvertAsync<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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

CreateDataConversionResult()

Creates a data conversion result.

Declaration
protected virtual IDataConversionResult CreateDataConversionResult()
Returns
Type Description
IDataConversionResult

The new data conversion result.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

Implements

ILoggable
IDataConversionService

Extension Methods

DynamicObjectExtensions.SetPropertyValue(Object, String, Object)
DynamicObjectExtensions.TrySetPropertyValue(Object, String, Object)
DynamicObjectExtensions.GetPropertyValue(Object, String)
DynamicObjectExtensions.TryGetPropertyValue(Object, String, out Object)
DynamicObjectExtensions.GetRuntimeTypeInfo(Object)
DynamicObjectExtensions.ToDynamic(Object)
DynamicObjectExtensions.ToExpando(Object)
BehaviorValue.ToBehaviorValue<TValue>(TValue)
CollectionExtensions.AddRange<T, TItem>(T, IEnumerable<TItem>)
LoggingExtensions.GetLogger(Object, IContext)
TypeExtensions.GetAbstractType(Object)
TypeExtensions.GetAbstractTypeInfo(Object)
ReflectionHelper.GetTypeInfo(Object)
EntityEntryExtensions.TryGetAttachedEntityEntry(Object)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX