Add File Type and Detectors and Mime Type tools and Refactor Grouping ...
This commit is contained in:
@@ -12,12 +12,13 @@ using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using xCommons.Interfaces;
|
||||
using xCommons.Providers;
|
||||
|
||||
namespace xCommons.Extensions
|
||||
{
|
||||
public static partial class DIExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Inject Specific Registered Service from IServiceCollection
|
||||
/// </summary>
|
||||
@@ -43,6 +44,41 @@ namespace xCommons.Extensions
|
||||
services.AddSingleton<XAppConfiguration>(appConfiguration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve and Register File Type Detector Configuration ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="configuration"></param>
|
||||
public static void AddXFileTypeDetectorConfiguration(
|
||||
this IServiceCollection source,
|
||||
IConfiguration configuration
|
||||
)
|
||||
{
|
||||
//
|
||||
var config = configuration.GetXFileTypeDetectorConfiguration();
|
||||
source.AddXFileTypeDetectorConfiguration(config);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register File Type Detector Configuration ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="configuration"></param>
|
||||
public static void AddXFileTypeDetectorConfiguration(
|
||||
this IServiceCollection source,
|
||||
XFileTypeDetectorConfiguration configuration
|
||||
)
|
||||
{
|
||||
//
|
||||
if (configuration.IsNull())
|
||||
{
|
||||
configuration = new();
|
||||
}
|
||||
|
||||
//
|
||||
source.AddSingleton(configuration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search Assemblies, Extract XML Comments and
|
||||
/// Integrate them inside swagger gen documents ...
|
||||
@@ -440,6 +476,16 @@ namespace xCommons.Extensions
|
||||
});
|
||||
}
|
||||
|
||||
public static void AddXFileTypeDetector(
|
||||
this IServiceCollection source,
|
||||
IConfiguration configuration
|
||||
)
|
||||
{
|
||||
//
|
||||
source.AddXFileTypeDetectorConfiguration(configuration);
|
||||
source.AddSingleton<IXFileTypeDetector, XFileTypeDetector>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use X Registered Cross Origin Resource Sharings
|
||||
/// </summary>
|
||||
|
||||
@@ -50,7 +50,29 @@ namespace xCommons.Extensions
|
||||
.GetSection(ConfigurationNodeNames.SWAGGER_NODE);
|
||||
return xSwaggerConfigSection.Get<XSwaggerConfiguration>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve File Type Detector Configuration ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XFileTypeDetectorConfiguration GetXFileTypeDetectorConfiguration(this IConfiguration source)
|
||||
{
|
||||
//
|
||||
var section = source
|
||||
.GetSection(ConfigurationNodeNames.FILE_TYPE_DETECTOR_NODE);
|
||||
|
||||
//
|
||||
var result = section.Get<XFileTypeDetectorConfiguration>();
|
||||
if (result.IsNull())
|
||||
{
|
||||
result = new();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ConfigurationSection to object Representation ...
|
||||
/// </summary>
|
||||
@@ -174,6 +196,6 @@ namespace xCommons.Extensions
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user