Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in
K
K13 .Net Core Xperience Adapter
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 1
    • Merge Requests 1
  • Operations
    • Operations
    • Metrics
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • Administrator
  • K13 .Net Core Xperience Adapter
  • Wiki
  • Usage Guidelines

Usage Guidelines

Last edited by eugene Oct 26, 2022
Page history

appsettings.json

  • Do no store sensitive information, especially passwords in appsettings.json, use the Secret Manager. Please see Safe storage of app secrets in development in ASP.NET Core for reference.

Models

  • Store all business class data models under <ProjectName>.Business/Models
  • Store all Kentico generated classes under <ProjectName>.Business/Models/Generated. No need to create subfolders unless the number of models is greater than 20, then logically group them in subfolders.
  • No need to add Dto in the class name, example HomePage, not HomePageDto
  • Name the model class the same as the Kentico Generated class, you just have a different namespace
    • Kentico Generated Class: CMS.DocumentEngine.Types.<ProjectName>.HomePage
    • Business Model Class: <ProjectName>.Business.Models.HomePage

Repositories

  • Create a repository for each PageType

  • Store all repositories under <ProjectName>.Business/Repositories. No need to create subfolders unless the number of repositories is greater than 20, then logically group them in subfolders.

  • Always inherit from XperienceAdapter.Repositories.BasePageRepository<<BusinessClass>, <GeneratedClass>>

    • public class HomePageRepository : BasePageRepository<HomePage, CMS.DocumentEngine.Types.<ProjectName>.HomePage>
  • If custom methods are needed to simplify data access to repositories, create an interface for the repository and have the repository inherit from both the interface and BasePageRepository.

    public interface IHomePageRepository
    {
        public HomePage GetHomePage();
    }
    
    public class HomePageRepository : BasePageRepository<HomePage, CMS.DocumentEngine.Types.<ProjectName>.HomePage>, IHomePageRepository
    {
        public HomePage GetHomePage()
        {
          ....
        }
    }

Navigation

  • Basic Navigation - Register NavigationRepository<NavigationItem> as INavigationRepository<NavigationItem> in the dependency injection container, e.g. AutoFac
  • CustomNavigation - Create a custom NavigationItem DTO and repository. See sample implementations in TestMenuPageDto and TestMenuPageRepository. You can then register NavigationRepository<TestMenuPageDto> as NavigationRepository<TestMenuPageDto> in the dependency injection container.

Unit Testing

  • Create unit tests for all repositories with custom methods, otherwise, not needed
  • Create unit tests for all components, mock repositories if retrieving data for the component

See Kentico Unit Testing (xUnit)

Clone repository
  • Package Releases
  • Usage Guidelines