Example #1
0
        /// <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);
        }
Example #2
0
		/// <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)});
		}
Example #3
0
 public ComplexTypeMap(MappingDepth mappingDepth, TDto dto, TEntity entity)
 {
     MappingDepth = mappingDepth;
     Entity       = entity;
     Dto          = dto;
 }
Example #4
0
 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) }));
        }
Example #6
0
 protected ValueMap(MappingDepth mappingDepth, TDto dto, TEntity entity)
 {
     MappingDepth = mappingDepth;
     Entity       = entity;
     Dto          = dto;
 }
Example #7
0
 public PrimitiveMap(MappingDepth mappingDepth, TDto dto, TEntity entity) : base(mappingDepth, dto, entity)
 {
 }