kastra.core 0.9.34

dotnet add package kastra.core --version 0.9.34
NuGet\Install-Package kastra.core -Version 0.9.34
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="kastra.core" Version="0.9.34">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add kastra.core --version 0.9.34
#r "nuget: kastra.core, 0.9.34"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install kastra.core as a Cake Addin
#addin nuget:?package=kastra.core&version=0.9.34

// Install kastra.core as a Cake Tool
#tool nuget:?package=kastra.core&version=0.9.34

Kastra.Core

The core library to build a Kastra website.

Build Status

Requirements

  • .NET Core 3.1

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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,076 10/6/2020
0.9.33 905 6/26/2020
0.9.32 997 6/2/2020
0.9.31 969 2/15/2020
0.9.30 998 2/2/2020
0.9.29 943 11/11/2019
0.9.28 895 11/5/2019
0.9.27 878 11/1/2019
0.9.26 928 10/21/2019
0.9.25 921 10/20/2019
0.9.24 982 10/13/2019
0.9.23 974 10/11/2019
0.9.22 915 10/8/2019
0.9.21 957 9/26/2019
0.9.20 2,332 7/28/2019
0.9.19 2,309 7/25/2019
0.9.18 2,301 7/21/2019
0.9.16 2,175 7/1/2019
0.9.15 2,562 4/29/2019
0.9.14 2,325 4/17/2019
0.9.13 2,722 1/28/2019
0.9.12 2,648 1/19/2019
0.9.11 2,546 12/11/2018
0.9.10 2,243 11/20/2018
0.9.9 2,574 11/19/2018
0.9.8 2,249 11/10/2018
0.9.7 2,328 11/2/2018
0.9.6 2,253 10/29/2018
0.9.5 2,431 9/20/2018
0.9.3 2,263 9/16/2018
0.9.0 2,397 9/5/2018
0.8.12 2,598 6/26/2018
0.8.10 2,567 6/5/2018
0.8.8 2,475 6/2/2018
0.8.7 2,498 6/2/2018
0.8.6 2,477 5/13/2018
0.8.5 2,359 5/8/2018
0.8.4 2,336 5/2/2018
0.8.3 2,519 3/31/2018
0.8.2 2,480 3/26/2018