public static CourseDto AdaptToDto(this Course p1)
        {
            if (p1 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p1, typeof(CourseDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((CourseDto)cache);
                }
                CourseDto result = new CourseDto(p1.CourseId, p1.Title, p1.Credits, funcMain1(p1.Enrollments));
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
        private static EnrollmentDto funcMain2(Enrollment p3)
        {
            if (p3 == null)
            {
                return(null);
            }
            MapContextScope scope = new MapContextScope();

            try
            {
                object cache;

                Dictionary <ReferenceTuple, object> references = scope.Context.References;
                ReferenceTuple key = new ReferenceTuple(p3, typeof(EnrollmentDto));

                if (references.TryGetValue(key, out cache))
                {
                    return((EnrollmentDto)cache);
                }
                EnrollmentDto result = new EnrollmentDto(p3.EnrollmentId, p3.CourseId, p3.StudentId, p3.Grade, funcMain3(p3.Course), funcMain4(p3.Student));
                references[key] = (object)result;
                return(result);
            }
            finally
            {
                scope.Dispose();
            }
        }
示例#3
0
 public MapsterAsyncEnumerator(IAsyncEnumerator <T> enumerator, IAdapterBuilder builder)
 {
     _enumerator = enumerator;
     _scope      = builder.CreateMapContextScope();
 }
示例#4
0
 public override object Map(object source, object destination, Type sourceType, Type destinationType)
 {
     using var scope = new MapContextScope();
     scope.Context.Parameters[DI_KEY] = _serviceProvider;
     return(base.Map(source, destination, sourceType, destinationType));
 }
示例#5
0
 public override TDestination Map <TSource, TDestination>(TSource source, TDestination destination)
 {
     using var scope = new MapContextScope();
     scope.Context.Parameters[DI_KEY] = _serviceProvider;
     return(base.Map(source, destination));
 }
示例#6
0
 public override TDestination Map <TDestination>(object source)
 {
     using var scope = new MapContextScope();
     scope.Context.Parameters[DI_KEY] = _serviceProvider;
     return(base.Map <TDestination>(source));
 }