コード例 #1
0
ファイル: TypeAdapterConfig.cs プロジェクト: peymannj/Mapster
        private TypeAdapterSettings CreateSettings(BaseAdaptAttribute attr)
        {
            var settings = new TypeAdapterSettings();
            var setter   = new TypeAdapterSetter(settings, this);

            setter.ApplyAdaptAttribute(attr);
            return(settings);
        }
コード例 #2
0
        public TwoWaysTypeAdapterSetter(TypeAdapterConfig config)
        {
            SourceToDestinationSetter = config.ForType <TSource, TDestination>();
            DestinationToSourceSetter = config.ForType <TDestination, TSource>();

            DestinationToSourceSetter.Unflattening(true);
            DestinationToSourceSetter.Settings.SkipDestinationMemberCheck = true;
        }
コード例 #3
0
ファイル: TypeAdapterConfig.cs プロジェクト: xcolon/Mapster
 public TypeAdapterConfig()
 {
     this.Rules   = RulesTemplate.ToList();
     this.Default = new TypeAdapterSetter(new TypeAdapterSettings(), this);
     this.Rules.Add(new TypeAdapterRule
     {
         Priority = (sourceType, destinationType, mapType) => - 100,
         Settings = this.Default.Settings,
     });
 }
コード例 #4
0
ファイル: TypeAdapterConfig.cs プロジェクト: qiqigou/Mapster
        private TypeAdapterSettings CreateSettings(BaseAdaptAttribute attr)
        {
            var settings = new TypeAdapterSettings();
            var setter   = new TypeAdapterSetter(settings, this);

            if (attr.IgnoreAttributes != null)
            {
                setter.IgnoreAttribute(attr.IgnoreAttributes);
            }
            if (attr.IgnoreNoAttributes != null)
            {
                setter.IgnoreMember((member, _) => !member.GetCustomAttributes(true)
                                    .Select(it => it.GetType())
                                    .Intersect(attr.IgnoreNoAttributes)
                                    .Any());
            }
            if (attr.IgnoreNamespaces != null)
            {
                foreach (var ns in attr.IgnoreNamespaces)
                {
                    setter.IgnoreMember((member, _) => member.Type.Namespace?.StartsWith(ns) == true);
                }
            }
            if (attr.IgnoreNullValues)
            {
                setter.IgnoreNullValues(attr.IgnoreNullValues);
            }
            if (attr.MapToConstructor)
            {
                setter.MapToConstructor(attr.MapToConstructor);
            }
            if (attr.MaxDepth > 0)
            {
                setter.MaxDepth(attr.MaxDepth);
            }
            if (attr.PreserveReference)
            {
                setter.PreserveReference(attr.PreserveReference);
            }
            if (attr.ShallowCopyForSameType)
            {
                setter.ShallowCopyForSameType(attr.ShallowCopyForSameType);
            }
            return(settings);
        }
コード例 #5
0
ファイル: MapDomainEventExtension.cs プロジェクト: qkb/MiCake
 /// <summary>
 /// Store aggregate domain Events to persistent object.
 /// </summary>
 /// <typeparam name="TAggregateRoot"><see cref="IAggregateRoot"/></typeparam>
 /// <typeparam name="TPersistentObject"><see cref="IPersistentObject"/></typeparam>
 public static TypeAdapterSetter <TAggregateRoot, TPersistentObject> MapDomainEvent <TAggregateRoot, TPersistentObject>(this TypeAdapterSetter <TAggregateRoot, TPersistentObject> setter)
     where TAggregateRoot : IAggregateRoot
     where TPersistentObject : IPersistentObject
 {
     return(setter.AfterMapping((s, d) => d.AddDomainEvents(s.GetDomainEvents())));
 }
コード例 #6
0
 /// <summary>
 /// Store aggregate domain Events to persistent object.
 /// </summary>
 /// <typeparam name="TEntity"><see cref="IEntity"/></typeparam>
 /// <typeparam name="TPersistentObject"><see cref="IPersistentObject"/></typeparam>
 public static TypeAdapterSetter <TEntity, TPersistentObject> MapDomainEvent <TEntity, TPersistentObject>(this TypeAdapterSetter <TEntity, TPersistentObject> setter)
     where TEntity : IEntity
     where TPersistentObject : IPersistentObject
 {
     return(setter.AfterMapping((s, d) => d.AddDomainEvents(s.GetDomainEvents())));
 }