kastra.core
0.9.30
See the version list below for details.
dotnet add package kastra.core --version 0.9.30
NuGet\Install-Package kastra.core -Version 0.9.30
<PackageReference Include="kastra.core" Version="0.9.30"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add kastra.core --version 0.9.30
#r "nuget: kastra.core, 0.9.30"
// Install kastra.core as a Cake Addin #addin nuget:?package=kastra.core&version=0.9.30 // Install kastra.core as a Cake Tool #tool nuget:?package=kastra.core&version=0.9.30
Kastra.Core
The core library to build a Kastra website.
Requirements
- .NET Core 3.0
Installation
Install the Kastra.Core nuget package in your .NET project
- .NET CLI :
$ dotnet add package kastra.core
or
- Nuget package manager :
$ Install-Package kastra.core
Usage
using Kastra.Core;
In startup.cs
In ConfigureServices method, you need to add :
- Kastra application options
- Kastra dependancy injections
- Kastra services
Note that after creating your Kastra application settings, you need to load Kastra business, DAL and modules assemblies with the DirectoryAssemblyLoader
static class.
An example of ConfigureServices method could be :
// Add options
services.AddOptions();
AppSettings appSettings = Configuration.GetSection("AppSettings").Get<AppSettings>();
services.Configure<AppSettings>(Configuration);
// Load assemblies
DirectoryAssemblyLoader.LoadAllAssemblies(appSettings);
// Add dependencies
var assemblies = KastraAssembliesContext.Instance.Assemblies.Values.ToArray();
services.AddDependencyInjection(Configuration, assemblies);
// Add Kastra default services
services.AddKastraServices();
services.AddMvc();
Make a template controller
If you want to use the default template controller, your controller must derive from TemplateController which is available in the Kastra.Core.Controllers namespace.
An example of a template controller could be :
using Kastra.Core;
using Kastra.Core.Controllers;
using Kastra.Core.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewComponents;
namespace Kastra.Web.Controllers
{
public class MyController : TemplateController
{
public MyController(IViewManager viewManager,
CacheEngine cacheEngine,
IViewComponentDescriptorCollectionProvider viewcomponents,
IParameterManager parameterManager)
: base(viewManager, cacheEngine, viewcomponents, parameterManager){}
}
}
Declare a module
You need to add a class which derives from ModuleBase class available in the Kastra.Core namespace.
The install method of the ModuleBase class will install automatically the module data in your website. These data must be in a fil named moduleconfig.json
.
An example could be :
ArticleModule.cs
public class ArticleModule : ModuleBase
{
public override void SetDependencyInjections(IServiceCollection services, IConfiguration configuration)
{
// Add services or dependancy injections
}
public override void Install(IServiceProvider serviceProvider, IViewManager viewManager)
{
base.Install(serviceProvider, viewManager);
// Add your specific code to install your module
}
public override void Uninstall()
{
// Add your specific code to uninstall your module
}
}
moduleconfig.json
{
"Modules": [{
"Definition": {
"SystemName": "Article",
"DisplayName": "Article",
"Namespace": "Kastra.Module.Article",
"Path": "Default/Article",
"Version": "1.0"
},
"Controls": [{
"KeyName": "Settings",
"Path": "Settings"
},
{
"KeyName": "Edit",
"Path": "Edit"
}
]
}]
}
Make a module view component in a module
To make a view component module, you can use the Kastra.Core.ViewComponents
namespace. Your view component must derive from ModuleViewComponent
class. You can use a model which must derive from ModuleModelBinder
class.
An example could be :
IndexViewComponent.cs
namespace Kastra.Module.Article
{
[ViewComponent(Name = "Kastra.Module.Article.Index")]
public class IndexViewComponent : ModuleViewComponent
{
private readonly ArticleContext _dbContext = null;
private readonly IArticleBusiness _articleManager = null;
public ArticleViewComponent(ArticleContext dbContext, IArticleBusiness articleBusiness)
{
_dbContext = dbContext;
_articleManager = articleBusiness;
}
public override ViewViewComponentResult OnViewComponentLoad()
{
IndexModel model = new IndexModel(this);
// Fill the model or do other thing here ...
return ModuleView("Index", model);
}
}
}
IndexModel.cs
namespace Kastra.Module.Article.Models
{
public class IndexModel: ModuleModelBinder
{
public IndexModel(ModuleViewComponent moduleView) : base(moduleView) { }
public IList<ArticleInfo> Articles { get; set; }
public Int32 PageId { get; set; }
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 3.1.1)
- Microsoft.Extensions.DependencyModel (>= 3.1.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on kastra.core:
Package | Downloads |
---|---|
Kastra.DAL.EntityFramework
Kastra data access layer |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.9.34 | 1,112 | 10/6/2020 |
0.9.33 | 932 | 6/26/2020 |
0.9.32 | 1,029 | 6/2/2020 |
0.9.31 | 989 | 2/15/2020 |
0.9.30 | 1,014 | 2/2/2020 |
0.9.29 | 967 | 11/11/2019 |
0.9.28 | 916 | 11/5/2019 |
0.9.27 | 900 | 11/1/2019 |
0.9.26 | 947 | 10/21/2019 |
0.9.25 | 945 | 10/20/2019 |
0.9.24 | 999 | 10/13/2019 |
0.9.23 | 991 | 10/11/2019 |
0.9.22 | 939 | 10/8/2019 |
0.9.21 | 980 | 9/26/2019 |
0.9.20 | 2,372 | 7/28/2019 |
0.9.19 | 2,362 | 7/25/2019 |
0.9.18 | 2,354 | 7/21/2019 |
0.9.16 | 2,221 | 7/1/2019 |
0.9.15 | 2,610 | 4/29/2019 |
0.9.14 | 2,362 | 4/17/2019 |
0.9.13 | 2,772 | 1/28/2019 |
0.9.12 | 2,669 | 1/19/2019 |
0.9.11 | 2,583 | 12/11/2018 |
0.9.10 | 2,309 | 11/20/2018 |
0.9.9 | 2,600 | 11/19/2018 |
0.9.8 | 2,279 | 11/10/2018 |
0.9.7 | 2,369 | 11/2/2018 |
0.9.6 | 2,284 | 10/29/2018 |
0.9.5 | 2,493 | 9/20/2018 |
0.9.3 | 2,319 | 9/16/2018 |
0.9.0 | 2,447 | 9/5/2018 |
0.8.12 | 2,655 | 6/26/2018 |
0.8.10 | 2,610 | 6/5/2018 |
0.8.8 | 2,549 | 6/2/2018 |
0.8.7 | 2,552 | 6/2/2018 |
0.8.6 | 2,535 | 5/13/2018 |
0.8.5 | 2,418 | 5/8/2018 |
0.8.4 | 2,388 | 5/2/2018 |
0.8.3 | 2,558 | 3/31/2018 |
0.8.2 | 2,534 | 3/26/2018 |