Skip to content

Commit

Permalink
Add ProjectToAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
chaowlert committed Feb 24, 2021
1 parent cd0095a commit d0c9c70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/Mapster.Async.Tests/AsyncTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using ExpressionDebugger;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;

Expand Down
13 changes: 13 additions & 0 deletions src/Mapster.Core/Attributes/BaseAdaptAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,17 @@ public class AdaptTwoWaysAttribute : AdaptToAttribute
public AdaptTwoWaysAttribute(Type type) : base(type) { }
public AdaptTwoWaysAttribute(string name) : base(name) { }
}

public class ProjectToAttribute : AdaptToAttribute
{
public ProjectToAttribute(Type type) : base(type)
{
MapType = MapType.Projection;
}

public ProjectToAttribute(string name) : base(name)
{
MapType = MapType.Projection;
}
}
}
2 changes: 1 addition & 1 deletion src/Mapster.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private static void GenerateExtensions(ExtensionOptions opt)
{
var tuple = new TypeTuple(type, toType);
var mapType = attr.MapType == 0
? MapType.Map | MapType.MapToTarget | MapType.Projection
? MapType.Map | MapType.MapToTarget
: attr.MapType;
GenerateExtensionMethods(mapType, cloned, tuple, translator, type, mapperAttr.IsHelperClass);
}
Expand Down

0 comments on commit d0c9c70

Please sign in to comment.