NeoConcept.Appfeatures
1.0.0
dotnet add package NeoConcept.Appfeatures --version 1.0.0
NuGet\Install-Package NeoConcept.Appfeatures -Version 1.0.0
<PackageReference Include="NeoConcept.Appfeatures" Version="1.0.0" />
paket add NeoConcept.Appfeatures --version 1.0.0
#r "nuget: NeoConcept.Appfeatures, 1.0.0"
// Install NeoConcept.Appfeatures as a Cake Addin #addin nuget:?package=NeoConcept.Appfeatures&version=1.0.0 // Install NeoConcept.Appfeatures as a Cake Tool #tool nuget:?package=NeoConcept.Appfeatures&version=1.0.0
.NET NeoConcept.Appfeatures
NeoConcept.Appfeatures provides a way to develop and expose application functionality based on features.
Many applications have special requirements when a new feature is developed such as when the feature should be enabled
and under whitch conditions
(example only user has role X
/ email Y
).
It's also very usefull for Saas cloud solutions editors who may manage application modularily depending on end user offer subscription.
Getting Started
1.Install the standard Nuget package into your ASP.NET Core application.
Package Manager : Install-Package NeoConcept.Appfeatures -Version 1.0.0
CLI : dotnet add package --version 1.0.0 NeoConcept.Appfeatures
2.In appsettings.json
file, add your MongoDb connection string or use existing MongoDb connection string
{
"DbSettings": {
"ConnectionString": "mongodb://dbuser:password@host:port/?tls=true",
"DatabaseName": "DbProd"
},
}
3.In the ConfigureServices
method of Startup.cs
, register the IAppFeatureService
.
using NeoConcept.Appfeatures;
IDbSettings configDb = Configuration.GetSection("DbSettings").Get<DbSettings>();
services.AddSingleton<IAppFeatureService, AppFeatureService>(x =>
new AppFeatureService(x.GetRequiredService<ILogger<AppFeatureService>>(), configDb.ConnectionString, configDb.DatabaseName)); ;
4.When using the NeoConcept.Appfeatures library, the IAppFeatureService
can be obtained through dependency injection.
public class HomeController : Controller
{
private readonly IAppFeatureService _appFeatureService;
public HomeController(IAppFeatureService appFeatureService)
{
_appFeatureService = appFeatureService;
}
}
Init Table AppFeatures
In the data.json
file, add app features settings :
Example:
[
{
"appName": "FirstApp",
"moduleName": "UserManagement",
"moduleDescription": "User Administration module"
}
]
Just after starting up your Asp.Net Core webHost , call InitAppFeature(jsonPath) method to init your AppFeature Mongo collection
string jsonFeaturePath = Path.Combine("data.json");
bool initAppFeatureResult = _appFeatureService.InitAppFeature(jsonFeaturePath);
Feature Check
The basic form of neoconcept.appfeatures is checking if a feature is enabled and then performing actions based on the result. This is done through the IAppFeatureService
's IsAppFeatureEnabled
method.
…
private readonly IAppFeatureService _appFeatureService;
public HomeController(IAppFeatureService appFeatureService)
{
_appFeatureService = appFeatureService;
}
…
if (_appFeatureService.IsAppFeatureEnabled("AppName","ModuleName"))
{
// Do something
}
Feature list
You can get all features by "AppName"
.
…
List<AppFeature> appFeature =_appFeatureService.AppFeatureList("AppName");
…
AppFeatures Collection
public class AppFeature: IAuditableEntity
{
[BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
[BsonId]
public string Id { get; set; }
public string AppName { get; set; }
public string ModuleName { get; set; }
public string ModuleDescription { get; set; }
public bool ModuleEnabled { get; set; } = false;
[BsonIgnoreIfNull]
public List<string> ModuleRoles { get; set; }
[BsonIgnoreIfNull]
public List<string> ModuleEmails { get; set; }
[BsonIgnoreIfNull]
public string CreatedBy { get; set; }
[BsonIgnoreIfNull]
public string UpdatedBy { get; set ; }
[BsonIgnoreIfNull]
public DateTime? UpdatedDate { get; set; }
[BsonIgnoreIfNull]
public DateTime? CreatedDate { get ; set; }
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net5.0
- Microsoft.Extensions.Logging.Log4Net.AspNetCore (>= 5.0.0)
- neoconcept.mongorepository (>= 5.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 232 | 12/30/2022 |