/// <summary> /// Finds the appropriate instance of <see cref="DtoMapVisitor{TDto, TEntity}"/> and performs mapping of DTO properties. /// </summary> /// <typeparam name="TDto">DTO type.</typeparam> /// <typeparam name="TEntity">Entity type.</typeparam> /// <param name="entity">The source object for mapping.</param> /// <param name="mappingDepth">Mapping depth configuration.</param> public static TDto Map <TDto, TEntity>(TEntity entity, MappingDepth mappingDepth) where TDto : class, new() where TEntity : class { if (mappingDepth == MappingDepth.None || entity == null || !DtoMapVisitorFactory.TryCreate <TDto, TEntity>(out var visitor) || visitor == null) { return(null); } TDto dto = new TDto(); new IdentityMap <TDto, TEntity>(mappingDepth, dto, entity).Accept(visitor); new PrimitiveMap <TDto, TEntity>(mappingDepth, dto, entity).Accept(visitor); new ComplexTypeMap <TDto, TEntity>(mappingDepth, dto, entity).Accept(visitor); return(dto); }
/// <summary> /// Creates a FactTypeMapsTowardsRole link in the same Partition as the given FactType /// </summary> /// <param name="source">FactType to use as the source of the relationship.</param> /// <param name="target">RoleBase to use as the target of the relationship.</param> /// <param name="depth">Initial value for the <see cref="Depth"/> property.</param> public static FactTypeMapsTowardsRole Create(FactType source, RoleBase target, MappingDepth depth) { if (source == null) { throw new ArgumentNullException("source"); } if (target == null) { throw new ArgumentNullException("target"); } MappingMandatoryPattern mandatoryPattern; MappingUniquenessPattern uniquenessPattern; GetMappingPatterns(target, out uniquenessPattern, out mandatoryPattern); return new FactTypeMapsTowardsRole( source.Partition, new RoleAssignment[] { new RoleAssignment(FactTypeMapsTowardsRole.FactTypeDomainRoleId, source), new RoleAssignment(FactTypeMapsTowardsRole.TowardsRoleDomainRoleId, target) }, new PropertyAssignment[] { new PropertyAssignment(DepthDomainPropertyId, depth), new PropertyAssignment(UniquenessPatternDomainPropertyId, uniquenessPattern), new PropertyAssignment(MandatoryPatternDomainPropertyId, mandatoryPattern)}); }
public ComplexTypeMap(MappingDepth mappingDepth, TDto dto, TEntity entity) { MappingDepth = mappingDepth; Entity = entity; Dto = dto; }
public IdentityMap(MappingDepth mappingDepth, TDto dto, TEntity entity) : base(mappingDepth, dto, entity) { }
/// <summary> /// Creates a FactTypeMapsTowardsRole link in the same Partition as the given FactType /// </summary> /// <param name="source">FactType to use as the source of the relationship.</param> /// <param name="target">RoleBase to use as the target of the relationship.</param> /// <param name="depth">Initial value for the <see cref="Depth"/> property.</param> public static FactTypeMapsTowardsRole Create(FactType source, RoleBase target, MappingDepth depth) { if (source == null) { throw new ArgumentNullException("source"); } if (target == null) { throw new ArgumentNullException("target"); } MappingMandatoryPattern mandatoryPattern; MappingUniquenessPattern uniquenessPattern; GetMappingPatterns(target, out uniquenessPattern, out mandatoryPattern); return(new FactTypeMapsTowardsRole( source.Partition, new RoleAssignment[] { new RoleAssignment(FactTypeMapsTowardsRole.FactTypeDomainRoleId, source), new RoleAssignment(FactTypeMapsTowardsRole.TowardsRoleDomainRoleId, target) }, new PropertyAssignment[] { new PropertyAssignment(DepthDomainPropertyId, depth), new PropertyAssignment(UniquenessPatternDomainPropertyId, uniquenessPattern), new PropertyAssignment(MandatoryPatternDomainPropertyId, mandatoryPattern) })); }
protected ValueMap(MappingDepth mappingDepth, TDto dto, TEntity entity) { MappingDepth = mappingDepth; Entity = entity; Dto = dto; }
public PrimitiveMap(MappingDepth mappingDepth, TDto dto, TEntity entity) : base(mappingDepth, dto, entity) { }