Dependency injection in extension methods

Extension methods are a great way to extend the functionality of objects. Sometimes, when extending an object, it is required to use some service and here comes a dependency injection. Developers use different approaches how to inject dependencies into an extension method. Some are better than others but some popular ones actually are anti-patterns.

Composition root in EPiServer

In the previous article, I described different dependency injection aspects and how those are applied in EPiServer. This article shows how composition root can be created for EPiServer MVC controllers.

Dependency injection in EPiServer

The concept of a dependency injection is simple - pass a dependent object in your object to use it. But that is not the only concept involved and some of the used concepts are better than others. In the EPiServer world, several patterns are used and misused.

Creating a simple coupon code discount

Coupon code discounts are one of the simplest discount types. All new EPiServer promotions can be configured to be applied with coupon code. In this article, I will show how to add a coupon code to an order and create a simple order discount using it.

Fixing InRiver multiple price import

In one EPiServer Commerce project, I needed to import multiple prices for a variation in different currencies from InRiver. InRiver has a connector for EPiServer but unfortunately it supports only one price per variation.

Registering multiple Dojo modules

EPiServer provides a way how to initialize Dojo modules in the module.config file. Unfortunately, you can set only one module initializer. In this article, I will describe how to solve this issue.

Enabling Commerce content selection

As EPiServer Commerce nodes, products and variations are EPiServer content, it is possible to create properties with content references to these. But by default EPiServer do not allow commerce content selection in edit mode.

Simple check if block is in edit mode

When working with EPiServer page views there is a useful property - PageEditing.PageIsInEditMode, which allows checking if the page is open in edit mode. But when working with block views, there is no such property.

EPiServer Marketing [Beta] - creating custom order promotion

Lately, I had to build a custom order promotion in one of our projects in Geta. We are using latest EPiServer Marketing features but unfortunately as it is in Beta still, its API changes quite often. I had to re-build my custom promotion already twice. In this article, I will describe how to build a custom order promotion with the latest EPiServer Commerce version (9.15.0).

Singleton page

Quite often when developing a website on EPiServer, I am creating page types which are used only for a single page. Such pages could be - cart page, order page, password reset page etc. To load such page, the pattern I use is adding properties with content references of those pages on the start page, then load start page and then load configured page. This sounds too complicated when I know that this page has only a single instance. Also, it is quite often that I forget to configure these pages for different environments. So few months ago I had an idea to create extension methods which would allow loading these pages in a simple way.

Scripting development environment

Recently, I installed and configured my new development computer. Manual application installation and configuration take a lot of time. In the Linux (Ubuntu) world you can use apt-get to script application installation, but for configuration can backup dotfiles on the old machine and restore on the new. Luckily there are some tools which will help you do same on Windows.

Fixing Dojo id conflict

Recently I got an error related to Dojo widget about conflicting id on the HTML element. While it is possible to work with Dojo without ids, those are necessary for field labels to work properly.

Feature folders vs Tech folders

For several years using ASP.NET MVC we tend to organize our code by Models, Controllers, and Views. In EPiServer development, we also split it more - into Page types, View models, and other types. But lately, developers started to realize that it is hard to manage such codebase and started to organize the code by features. In this article, I will analyze both approaches using Dependency Structure Matrix.

EPiServer custom tab ordering

EPiServer allows us to group content's properties into different tabs using GroupName parameter on DisplayAttribute. While it works fine, it doesn't order tabs I want. In this article, I will show a simple declarative way to control tab ordering.

Maintaining private ASP.NET and EPiServer configuration

Maintaining local development or private (secret) configuration in .NET always was hard. There is no single path how to do it. Two days ago Scott Hanselman wrote an article about best practices for private config data. He describes existing way how to put configuration into an external file (which already existed since .NET 1.1 and 2.0 :) ), but there are still some open questions. In this article, I am going to show one way how to solve these configuration issues.