-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
311 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/Antelcat.AutoGen.Sample/Extensions/Mapping/MapExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Antelcat.AutoGen.ComponentModel.Mapping; | ||
using Antelcat.AutoGen.Sample.Models.Mapping; | ||
|
||
namespace Antelcat.AutoGen.Sample.Extensions.Mapping; | ||
|
||
public static partial class MapExtension | ||
{ | ||
[AutoMap(Extra = [nameof(Test)])] | ||
public static partial Antelcat.AutoGen.Sample.Models.Mapping.SampleEntity ToEntity(this SampleDto dto); | ||
|
||
|
||
public static void Test() | ||
{ | ||
new SampleDto("").ToEntity(); | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
src/Antelcat.AutoGen.Sample/Models/Accessor/INeedAccessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Antelcat.AutoGen.ComponentModel; | ||
|
||
namespace Antelcat.AutoGen.Sample.Models.Accessor; | ||
|
||
[AutoKeyAccessor] | ||
public partial interface INeedAccessor | ||
{ | ||
public string A => nameof(A); | ||
} | ||
|
||
public class NeedBase | ||
{ | ||
public virtual int D { get; set; } | ||
} | ||
|
||
[AutoKeyAccessor(includeField: true, Get = false)] | ||
public partial class NeedAccessor : NeedBase, INeedAccessor | ||
{ | ||
public int B { get; set; } | ||
|
||
public override int D { get; set; } | ||
|
||
private int d; | ||
} | ||
|
||
[AutoKeyAccessor] | ||
public partial struct StructAlsoNeedAccessor | ||
{ | ||
public byte C | ||
{ | ||
set { } | ||
} | ||
} |
5 changes: 1 addition & 4 deletions
5
...t.AutoGen.Sample/Models/FileDescriptor.cs → ...n.Sample/Models/Mapping/FileDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...telcat.AutoGen.Sample/Models/SampleDto.cs → ...utoGen.Sample/Models/Mapping/SampleDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...cat.AutoGen.Sample/Models/SampleEntity.cs → ...Gen.Sample/Models/Mapping/SampleEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Antelcat.AutoGen.Shared/ComponentModel/AutoKeyAccessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using Antelcat.AutoGen.ComponentModel.Abstractions; | ||
|
||
namespace Antelcat.AutoGen.ComponentModel; | ||
|
||
/// <summary> | ||
/// Auto generate key accessor for the target type, default to properties | ||
/// </summary> | ||
/// <param name="includeInherited">include inherited members</param> | ||
/// <param name="includeField">include fields</param> | ||
/// <param name="accessibility">this property accessibility</param> | ||
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] | ||
public class AutoKeyAccessor( | ||
bool includeInherited = true, | ||
bool includeField = false, | ||
Accessibility accessibility = Accessibility.Public) | ||
: AutoGenAttribute | ||
{ | ||
internal readonly Accessibility Accessibility = accessibility; | ||
internal readonly bool IncludeInherited = includeInherited; | ||
internal readonly bool IncludeField = includeField; | ||
|
||
/// <summary> | ||
/// accessor can get, default true | ||
/// </summary> | ||
public bool Get { get; set; } = true; | ||
|
||
/// <summary> | ||
/// accessor can set, default true | ||
/// </summary> | ||
public bool Set { get; set; } = true; | ||
|
||
public string[]? Ignores { get; set; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.