-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #428 from Respawnsive/apizr
Add the possibility to generate all the Apizr goodness
- Loading branch information
Showing
21 changed files
with
1,393 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,29 @@ | ||
using System.Collections.Concurrent; | ||
using System.ComponentModel; | ||
using System.Reflection; | ||
|
||
namespace Refitter.Core | ||
{ | ||
internal static class EnumExtensions | ||
{ | ||
private static readonly ConcurrentDictionary<string, string> DescriptionCache = new(); | ||
|
||
public static string ToDescription(this Enum value) | ||
{ | ||
var key = $"{value.GetType().FullName}.{value}"; | ||
|
||
var displayName = DescriptionCache.GetOrAdd(key, _ => | ||
{ | ||
var name = (DescriptionAttribute[])value! | ||
.GetType()! | ||
.GetTypeInfo()! | ||
.GetField(value.ToString())! | ||
.GetCustomAttributes(typeof(DescriptionAttribute), false); | ||
|
||
return name.Length > 0 ? name[0].Description : value.ToString(); | ||
}); | ||
|
||
return displayName; | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Text; | ||
|
||
namespace Refitter.Core.Settings | ||
{ | ||
public enum ApizrPackages | ||
{ | ||
[Description("dotnet add package Apizr")] | ||
Apizr = 1, | ||
|
||
[Description("dotnet add package Apizr.Extensions.Microsoft.DependencyInjection")] | ||
Apizr_Extensions_Microsoft_DependencyInjection = 2 | Apizr, | ||
|
||
[Description("dotnet add package Apizr.Integrations.Akavache")] | ||
Apizr_Integrations_Akavache = 4 | Apizr, | ||
|
||
[Description("dotnet add package Apizr.Integrations.MonkeyCache, then write somewhere: Barrel.ApplicationId = \"YOUR_APPLICATION_NAME\";")] | ||
Apizr_Integrations_MonkeyCache = 8 | Apizr, | ||
|
||
[Description("dotnet add package Apizr.Integrations.Fusillade")] | ||
Apizr_Integrations_Fusillade = 16 | Apizr, | ||
|
||
[Description("dotnet add package Apizr.Integrations.AutoMapper, then register AutoMapper")] | ||
Apizr_Integrations_AutoMapper = 32 | Apizr, | ||
|
||
[Description("dotnet add package Apizr.Integrations.Mapster, then register Mapster")] | ||
Apizr_Integrations_Mapster = 64 | Apizr, | ||
|
||
[Description("dotnet add package Apizr.Integrations.FileTransfer")] | ||
Apizr_Integrations_FileTransfer = 128 | Apizr, | ||
|
||
[Description("dotnet add package Apizr.Extensions.Microsoft.Caching, then register your caching provider")] | ||
Apizr_Extensions_Microsoft_Caching = 256 | Apizr_Extensions_Microsoft_DependencyInjection, | ||
|
||
[Description("dotnet add package Apizr.Extensions.Microsoft.FileTransfer")] | ||
Apizr_Extensions_Microsoft_FileTransfer = 512 | Apizr_Integrations_FileTransfer | Apizr_Extensions_Microsoft_DependencyInjection, | ||
|
||
[Description("dotnet add package Apizr.Integrations.MediatR, then register MediatR")] | ||
Apizr_Integrations_MediatR = 1024 | Apizr_Extensions_Microsoft_DependencyInjection, | ||
|
||
[Description("dotnet add package Apizr.Integrations.FileTransfer.MediatR, then register MediatR")] | ||
Apizr_Integrations_FileTransfer_MediatR = 2048 | Apizr_Integrations_MediatR | Apizr_Extensions_Microsoft_FileTransfer, | ||
|
||
[Description("dotnet add package Apizr.Integrations.Optional, then register MediatR")] | ||
Apizr_Integrations_Optional = 4096 | Apizr_Integrations_MediatR, | ||
|
||
[Description("dotnet add package Apizr.Integrations.FileTransfer.Optional, then register MediatR")] | ||
Apizr_Integrations_FileTransfer_Optional = 8192 | Apizr_Integrations_Optional | Apizr_Integrations_FileTransfer_MediatR, | ||
} | ||
} |
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,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Refitter.Core | ||
{ | ||
/// <summary> | ||
/// Describing how Apizr should be configured. | ||
/// Here are only the common configurations. | ||
/// </summary> | ||
public class ApizrSettings | ||
{ | ||
/// <summary> | ||
/// Set it to true to include an Apizr Request Options parameter into all api methods | ||
/// and get all the Apizr goodness (default: true) | ||
/// </summary> | ||
public bool WithRequestOptions { get; set; } = true; | ||
|
||
/// <summary> | ||
/// Set it to true to generate an Apizr registration helper ready to use (default: false). | ||
/// Please note that it will generate an extended or static helper depending on DependencyInjectionSettings property value. | ||
/// </summary> | ||
public bool WithRegistrationHelper { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Library to use for cache handling (default: None) | ||
/// Options: | ||
/// - None | ||
/// - Akavache | ||
/// - MonkeyCache | ||
/// - InMemory (Microsoft.Extensions.Caching.Memory) | ||
/// - Distributed (Microsoft.Extensions.Caching.Distributed) | ||
/// </summary> | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public CacheProviderType WithCacheProvider { get; set; } | ||
|
||
/// <summary> | ||
/// Library to use for data mapping handling (default: None) | ||
/// Options: | ||
/// - None | ||
/// - AutoMapper | ||
/// - Mapster | ||
/// </summary> | ||
[JsonConverter(typeof(JsonStringEnumConverter))] | ||
public MappingProviderType WithMappingProvider { get; set; } | ||
|
||
/// <summary> | ||
/// Set it to true to handle request with priority (default: false) | ||
/// </summary> | ||
public bool WithPriority { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Set it to true to handle request with MediatR (default: false) | ||
/// </summary> | ||
public bool WithMediation { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Set it to true to handle request with MediatR and Optional result (default: false) | ||
/// </summary> | ||
public bool WithOptionalMediation { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Set it to true to manage file transfers (default: false) | ||
/// </summary> | ||
public bool WithFileTransfer { get; set; } = false; | ||
} | ||
} |
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,12 @@ | ||
namespace Refitter.Core | ||
{ | ||
public enum CacheProviderType | ||
{ | ||
None, | ||
Akavache, | ||
MonkeyCache, | ||
InMemory, | ||
DistributedAsString, | ||
DistributedAsByteArray, | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Refitter.Core | ||
{ | ||
public enum MappingProviderType | ||
{ | ||
None, | ||
AutoMapper, | ||
Mapster | ||
} | ||
} |
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.